1

How to run a script at Login screen (BEFORE user types password to log in)?

I have tried launchctl and place the script under both:

/Library/LaunchDaemons/
/Library/LaunchAgents/

Still the script is executed AFTER log in.

Am I missing something?

Edit:

  • I tried /Library/StartupItems also didn't work. Is the LaunchDaemons supposed to launch after Login or before. Have anyone successfully make it run before Login?
  • I'm running on Yosemite.
4
  • Do you mean whenever the login screen is shown, or just once after booting your Mac?
    – Arjan
    Nov 1, 2014 at 10:30
  • Either of them is ok, just before the user log in. Calling the script once, or whenever (multiple times) are both fine.
    – An Phung
    Nov 1, 2014 at 12:19
  • are you talking about login after boot? or do you mean the password right afterstarting the computer? As the later is requesting the password to unlock your filevaulted harddrive nothing on that harddrive can be executed before. Nov 1, 2014 at 19:47
  • As in my computer, I only have to enter 1 password at login screen. (After pressing power button -> Apple logo -> Login screen -> Enter password -> Load to desktop)
    – An Phung
    Nov 2, 2014 at 4:14

2 Answers 2

0

Add this to your crontab:

@reboot /path/to/file.sh

The script will be run once on boot before login.

1
  • Still execute after logging in.
    – An Phung
    Nov 1, 2014 at 15:15
0

After trying many the ways, I realize that FileVault might cause this behavior. Because FileVault requires password in order to decrypt the data, we cannot do anything before entering the password.

This is a conjecture, if someone has any information about this, please feel free to confirm.

If anyone has a work around, please feel free to help.

You must log in to answer this question.

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