Kace Script: Complex weekly reboot
Here is what I'd like to script, but haven't seen much similar yet in my googling:
-If no user is logged in - reboot
-If user is logged in - check to see if winword.exe or excel.exe are running
-If either are running prompt user to save all documents and then reboot
-Dialog options: OK (Reboot now), Snooze (but re-prompt after 1 hour)
-If neither process is running - reboot
I see that I can get Kace to check for running processes, and have done this for scripts successfully. I don't see how I can get user prompts for input within a single Kace script (the OK or Snooze buttons), it seems like only static message boxes are an option.
So as a work around I was thinking seperate scripts:
-Script one: Checks for the running processes and if they are running leaves a flag file (C:\promptforreboot.txt or something)
-Script two: Anything with that flag file gets the "Alert User Before Run" dialog, with OK causing a reboot and Snooze snoozing for 1 hour
-Script three: Anything without the processes running, and without a flag file gets rebooted immediately
That's all pretty awkward to make work, and I feel like there is room for error. Any tips?
Community Chosen Answer
Have you looked at AutoIt? I use this to create exe's that perform certain tasks.
Compile the script below into an exe. Then upload the exe as a dependency.
Sample Reboot Script:
$answer = MsgBox(1, "Reboot", "Some Text.....Click OK to reboot now.") If $answer = 1 Then Shutdown(6) EndIf If $answer = 2 Then Exit EndIf