Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Jan 31, 2009, 01:41 AM   #1
macrumors newbie
Join Date: Jun 2007
Anyone good with Applescript?

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.

DAlba is offline   0 Reply With Quote
Old Jan 31, 2009, 11:02 AM   #2
macrumors 6502a
Sayer's Avatar
Join Date: Jan 2002
Location: 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).
Obama is a true statesman whose experience as a state senator, half-term US Senator & guest lecturer in a Constitutional Law class has fully prepared him to take control of our nuclear arsenal.-Me
Sayer is offline   0 Reply With Quote
Old Feb 1, 2009, 09:08 AM   #3
macrumors member
Join Date: Aug 2008
Location: 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.


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.
andmr is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Purchasing MacBook Pro for Music Production- Is This MBP Good Enough/Good Deal? Goalyguy33 MacBook Pro 14 Oct 20, 2014 03:57 PM
Photo printing app with good prices and good service? Meg2014 iPhone and iPod touch Apps 1 May 29, 2014 11:11 PM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Programming 0 Oct 28, 2013 11:38 PM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Applications and Mac App Store 0 Oct 28, 2013 11:32 PM
Feel Good Stories about Retina MBP share your good experience MaxPower72 MacBook Pro 9 Sep 21, 2012 07:45 AM

Forum Jump

All times are GMT -5. The time now is 09:15 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC