2

I need to run an application behind the lock screen, e.g., just as Time Machine or Sophos antivirus (and others) can run when the screen is locked.

Specifically, I would like to schedule an application to launch when the computer is asleep and unattended (but not powered off). The plan is to schedule wake via Energy Saver or pmset, and use iCal/Automator to schedule the app launch. The problem I'm encountering is the lock screen (ie System Pref > Security > Require Password). When the lock screen is enabled the application will not launch unattended - a user must enter the password. By way of debugging I have confirmed that disabling lock screen allows the app to launch, but this is not a solution due to the security issues.

Bottom line: Is there a way to schedule an applescript or shell script (perhaps with root privileges) to grant the lock screen access to the password? I'm thinking KeyChain should be able to do this, but I can't figure out how. Or perhaps there are other solutions?

Other details: - I'm running 10.7 and 10.9.

4
  • No, if you could control PC while it's lock, it would kinda make it useless to lock it. You could create a Launch Daemon, though I don't know how safe it will be to give it access to your password. Better would be to make the Launch Daemon to start the app, but I'm pretty sure the app won't be able to fully function unless you are logged in.
    – user14492
    Aug 9, 2015 at 1:23
  • --> Re lock screen being useless. NOT so! There are many processes that run behind the lock screen. Time Machine is as good example! There is no problem running behind the lock screen as long as an admin user pre-authorized that process to do so. That's all I'm trying to do. Using KeyChain would securely allow the indicated process to run while excluding all others. --> Launch Daemon would not help. The computer is only asleep, not powered off.
    – paamachat
    Aug 9, 2015 at 13:07
  • Process like Time-Machine, and maintenance scripts they were specially designed, and integrated in the OS by Apple, so they can run. But you cannot create a process to start running while it's locked, even if you have admin privileges.
    – user14492
    Aug 9, 2015 at 16:26
  • 3rd part apps can do this, e.g. Sophos Antivirus. I've seen it myself. It will launch a scheduled virus scan when the computer is asleep and locked. So there must be a way to work behind the lock screen. I just want to replicate that behavior. Thanks.
    – paamachat
    Aug 9, 2015 at 16:51

1 Answer 1

1

Power Manager

If you are happy to use a third party application, Power Manager can do exactly what you want.

There are lots of recipes to help create your schedule. For your situation:

By default, Power Manager will power on a sleeping Mac to perform scheduled events. The recipe above for launching an application will automatically wake a sleeping Mac. You can adjust the event to power on a shut down Mac, if desired.

Power Manager will launch your application behind the lock screen. This is possible because Power Manager has a helper agent running within each user session. The main scheduler works with the agent to make sure the application is launched in the right user session.

DssW Power Manager on OS X

Disclosure: I work for DssW, who make Power Manager; so feel free to ask technical questions.

Fast User Switch

If you are concerned about security, consider having the user be switched back to the login window with Fast User Switching.

While Fast User Switched, your Mac can wake to schedule, run the AppleScript, and complete its task while not risking unguarded access to the Mac.

2
  • Thanks. As this is a one-off problem I was hoping for a less expensive solution, even if it required more effort :)
    – paamachat
    Aug 9, 2015 at 17:38
  • No problem. What you want is possible to achieve but it may require more than AppleScript can offer. Aug 9, 2015 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .