Pumagaju Posted January 5, 2009 Posted January 5, 2009 I have a script to run gpudate /force. After completion I want them to reboot without forcing them. However, if after two hours they havent rebooted I want to do a force shutdown. Anyone know of a function that will allow for a "click now" to reboot and/or then wait routine? Here is my script so far: RunWait(@ComSpec & " /c " & "gpupdate /force", "", @SW_HIDE) Sleep(200000);two hours MsgBox(64, "SIC - Complete", "You are now being rebooted.") Shutdown(6) ;Force a reboot Thanks,
youknowwho4eva Posted January 5, 2009 Posted January 5, 2009 Easiest way would be to make a gui. then user _timer_init and covert out 2 hours to milliseconds. Giggity
Pumagaju Posted January 5, 2009 Author Posted January 5, 2009 Easiest way would be to make a gui. then user _timer_init and covert out 2 hours to milliseconds.Can anyone point me to some resources for creating such a gui?Thanks,
Pumagaju Posted January 5, 2009 Author Posted January 5, 2009 Easiest way would be to make a gui. then user _timer_init and covert out 2 hours to milliseconds.So I have created a basic gui to meet my needs. However, I have come across one small glitch. If the user chooses the "wait" option then the gui box doesnt go away. Is there any way to clear that so that while the script continues to run? Here is my code: #include <GUIConstantsEx.au3> GUICreate("Action Required", 300, 100) GUICtrlCreateLabel("Please choose which reboot option works best for you:", 30, 10) $okbutton = GUICtrlCreateButton("Reboot Now", 50, 50, 70) $ok2button = GUICtrlCreateButton("Reboot in 2 Hours", 150, 50, 100) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg(1) Select Case $msg = $okbutton Shutdown(6) ;Force a reboot Case $msg = $ok2button MsgBox(0, "Alert", "You're machine will reboot two hours from now!") ExitLoop EndSelect WEnd Sleep(200000) ;two hours Shutdown(6) ;Force a reboot Thanks,
shanesloan Posted January 5, 2009 Posted January 5, 2009 If you're working in windows, you could just use the command-line call 'shutdown' via a shellexecuteHere's the code necessary in AutoIt:ShellExecute( "CMD.exe", "/C shutdown -r -t 7200" )This will launch a shutdown dialog with a timeout of 7200 ( this is seconds ). If you want to see how it works outside of AutoIt, then in a command window type: shutdown -r -t 01. The computer will restart after 1 second.This will allow you to finish execution on the original script and then windows will take care of the reboot. Alternately, If you want to handle the reboot inside AutoIt, then you may want to use TimerInit() and TimerDiff().
FireFox Posted January 5, 2009 Posted January 5, 2009 @Pumagaju $GUI = GuiCreate(...) GuiSetState(@SW_HIDE, $GUI) Cheers, FireFox
Pumagaju Posted January 5, 2009 Author Posted January 5, 2009 Awesome! Thanks for the help. Those ideas work great! I appreciate your help. Gary
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now