Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DAlba

macrumors newbie
Original poster
Jun 30, 2007
25
0
Is anyone here good with Applescript? I have spent hours trying to figure this out but I am completely lost!

Here's what I need....
Every hour or so I would like a dialog window to pop up saying something like this... computer will restart in 60 seconds...to continue working click cancel.
if cancel isn't selected then i want the mac to restart. its important that it bypasses any save dialogue windows though and always completes the restart so maybe it would have to force quite all apps first. Thats it!

In case your wondering this is for several macs in a retail store. we have a program called deep freeze on them which restores the machine to a frozen state once restarted. this way when customers mess something up a simple restart ensures everything is how it should be.

Any help would be greatly appreciated.

Thanks
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Why not just set up a non-Admin, restricted account? You can use Parental controls to prevent editing the dock, access to System Prefs and more.

There is also the Guest account option that deletes all data on logout. I dont know if you can set a Guest account to automatically log in or not (wife is using the iMac and I am on my DELL Craptop from work).
 

andmr

macrumors member
Aug 25, 2008
31
0
NE Florida
This worked for me:

display dialog "This computer will restart in 60 seconds... to continue working click Cancel." with icon caution buttons {"Cancel", "Restart"} default button "Cancel" giving up after 60
if button returned of result is not "Cancel" then
tell application "System Events" to set the_apps to name of every application process whose visible is true or (background only is false and visible is false) and name is not "Finder"
repeat with each_app in the_apps
tell application each_app to quit without saving -- WARNING: "without saving" will override dialog boxes; unsaved changes in open documents will be lost!
end repeat
tell application "System Events" to restart
else if button returned of result is "Cancel" then
end if


Save the script as an application bundle, Options off, and set it to open once every hour using CronniX.

Notes:

The computer will restart if the user takes no action after 60 seconds once the dialog appears, or if the user presses Restart. The only way to prevent a restart is by pressing Cancel.

Although you may be aware of the consequences of using "quit without saving" in the script, the warning comment is included for those who may not be, just in case.

Using CronniX:

1) From the File menu select either Open for User or Open System Crontab. From the toolbar click on New to create a new crontab entry.

2) Choose a "Simple" schedule if you want the script to run, for example, every day at 15 minutes after every hour. Do this by checking "All" for Day of week, Month, Day of month, Hour; and move the Minute slider to the right until you reach 15 (the number 15 means fifteen minutes after the hour, not every fifteen minutes).

3) Press the Browse button, navigate to the saved script app and press Insert. Check: prepend "/user/bin/open" and press New. Save changes and quit CronniX

Good luck.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.