Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 31, 2009, 01:41 AM   #1
DAlba
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.

Thanks
DAlba is offline   0 Reply With Quote
Old Jan 31, 2009, 11:02 AM   #2
Sayer
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
andmr
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.

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

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
anyone good with mini vMac for win xp? Rhetro Apple Collectors 3 Nov 21, 2007 12:26 PM
Anyone good with Applescript and Perl? PuNkErX Mac Programming 3 Oct 14, 2006 10:27 AM
Anyone good with a Mac Plus and disk images? Rhetro Apple Collectors 4 Aug 14, 2006 06:04 PM
Anyone good with Algebra??? rdf8585 Community Discussion 24 Jul 6, 2006 09:58 PM
Anyone good with GarageBand willing to help me out? hotwire132002 Digital Audio 15 Oct 31, 2004 11:47 AM


All times are GMT -5. The time now is 12:13 PM.

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

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