Random Prompt for password or force shutdown

Well hello everyone!:smiley:

Would anyone be able to help me in creating an AppleScript that does the following:

At random intervals but at least once every 30 minutes i would like OS X to prompt the user for a password, allow them 20 seconds to enter the password and then allow them to continue if the password is correct. If the password is not entered or is incorrect i would like the script to kill everything and shutdown the computer.

Is this possible?

Many thanks in advance

Mat :smiley:

Yes. Here’s a script. Modify it to your liking.

For this to work, you have to save it as a “Stay Open” application. When you save it as an application in Script Editor, check the Stay Open checkbox.

on idle
	set thePass to text returned of (display dialog "Enter password:" default answer "" buttons {"OK"} default button 1 with hidden answer)
	if thePass is not "thisIsThePassword" then tell application "Finder" to shut down
	return (60 * 30) --this sets the time until the next turn, in seconds
end idle

Also save the app as Run Only, so that no one can read the password.

Just open the application and leave it running in the background. If you always want it to be on, add it to the startup items list in System Prefs.

Hope this helps!!! :slight_smile:

Wow that was a quick response! Thankyou!

I have just tried the script and it works well except if the user enters nothing and moves the box out of the way it will not shut down the computer. Is there any way to make it shutdown the computer if they have entered nothing after 20 secs?

Thanks again!!


Still in the parenthesis, after the “With hidden answer” type

“giving up after 20”

Have a good day!

Fantastic!! Works Great Your A Star!!

Thankyou Very Very Much