GUI script to reboot a Windows partition back to an OS X partition

Jun 03, '11 07:30:00AM

Contributed by: tom larkin

You can use AutoIT, a free basic-like GUI scripting application to automate the bootcamp.exe in Windows to force a reboot back into OS X.

This is sort of part 2 to my previous hint found here. This AutoIT script can be automated by whatever mechanism you use to manage a Windows partition on your Macs, like Active Directory, Citrix, Novell/Netware, SCCM, or other third party tools to run scripts and policies in your enterprise.

It basically just opens the Boot Camp executable file in Windows and then simulates mouse clicks. This is how I forced users back into OS X after non admins would boot into Windows. Here is the script:

;; boot_to_osx.au3
;;
;; there's no way to do this with the command line or anything,
;; so here's a little autoit script to use apple's provided
;; utility to bless the OSX drive.
 
#requireadmin
Local $dom = envget("USERDOMAIN")
;;runas("maptestadmin",$dom,"m4pt3st",0,"C:\Windows\system32\AppleControlPanel.exe")
Run("C:\Windows\system32\AppleControlPanel.exe")
WinWait("Boot Camp Control Panel")
WinActivate("Boot Camp Control Panel")
WinWaitActive ("Boot Camp Control Panel")
ControlClick ("Boot Camp Control Panel", "", "[CLASSNN:SysListView321]", "left", 1, 40, 20)
ControlClick("Boot Camp Control Panel", "OK", 1)
Run("C:\Windows\system32\shutdown.exe -f -r -t 0")
You can find the AutoIT software from their site, and it is a free product. In our case we had Zen Works auto launch and monitor our testing application that users needed to use Windows on. Once that process was terminated in any way at all, the AutoIT script kicked off and forced a user back into OS X. We only wanted our users using Windows for that single application and nothing else.

[crarko adds: I haven't tested this one.]

Comments (3)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20110602112643936