Mac Management Group

 View Only

Mac OS X Reboot Deferral 

May 16, 2011 11:37 AM

Using CMS 7.x to install software updates on the Mac works quite well.  Before installing updates there is a built-in mechanism with Task Server to notify the end user.  Once updates have installed, the Mac will automatically restart as the system is left in an unstable state.  I have been asked by users how they can insert one last dialog box to warn users that a restart is about to occur and possibly allow them to defer it just long enough to save work, etc.  Using Applescript, here is a sample script that can be incorporated into the patch workflow.  I would recommend you copy and paste the script into AppleScript Editor to make sure it compiles and runs.  Sometimes copy and paste will introduce errors.  Then, create a new Run Script task and select Applescript.  Then, copy and post the working code and Save.  Then, insert the script as part of the patching process, and viola!  you have your very own patch reboot deferral!

 

 repeat

tell application "System Events" to display dialog "A restart is required to finish installing new software.

Please select Postpone to be prompted again in 1 minute or OK to restart now." buttons {"Postpone", "OK"} default button 1 giving up after 3600 with icon 0

if button returned of result = "OK" then

return 0

else if button returned of result = "Postpone" then

try

delay 60 #re-prompt user to restart every 60 seconds

end try

end if

end repeat 

Statistics
0 Favorited
1 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Jul 21, 2016 11:23 AM

Since it is an interactive script, the NS task has to run as the current logged on user in order for the pop-up window to have a place to display. In the task, open the advanced settings and make that change. 

Aug 01, 2012 09:39 AM

I attempted to add this script in Symantec Management Console 7.1.8280. I created a new script, selected Applescript as the script type in Jobs/Tasks to test and applied to a Mac running OS 10.7.3. The script runs fine from withing Applescript editor on the local machine, but running as a script from Jobs/Tasks the script fails with an error in the client task history:

Execution result: 1, Script failed by exitingwith a non-zero return code

I am sure I am missing something. Any suggestions would be helpful!

Related Entries and Links

No Related Resource entered.