Naveed Posted May 25, 2010 Posted May 25, 2010 I am creating a monitor tool that myself and other network administrators can use to reboot a remote server / machine and monitor it while it reboots. Here is the code i tried to put together myself, i can reboot the machine no problem but getting the script to keep track is the hard bit. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ProgressConstants.au3> Call("Reboot") Func Reboot() Local $msg GUICreate("My GUI") GUISetState(@SW_SHOW) Run("cmd.exe /k" & "shutdown -r -m \\" & "computername" & " -t 3 -f", "", @SW_HIDE) ProcessClose("cmd.exe") ProcessWaitClose("cmd.exe", 2) While 1 $online = Ping("asst131161") GUICtrlCreateLabel("Machine is Online, Waiting for Shutdown", 10, 30) If $online = 0 Then ExitLoop WEnd GUICtrlCreateLabel("Machine has Rebooted", 60, 30) Sleep(5000) GUIDelete($msg) EndFunc Any help will be appreciated, and thanks in advance...
PsaltyDS Posted May 25, 2010 Posted May 25, 2010 Don't ever create the same control over and over like that: $sRemoteComputer = "asst131161" $idLabel = GUICtrlCreateLabel("Machine is Online, Waiting for Shutdown", 10, 30) Run("cmd.exe /k" & "shutdown -r -m \\" & $sRemoteComputer & " -t 3 -f", "", @SW_HIDE) While Ping($sRemoteComputer) GUICtrlSetData($idLabel, "Machine is Online, shuting down...") WEnd While Not Ping($sRemoteComputer) GUICtrlSetData($idLabel, "Machine is Offline, rebooting...") WEnd GUICtrlSetData($idLabel, "Machine is back Online, reboot complete.") Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Naveed Posted May 27, 2010 Author Posted May 27, 2010 Don't ever create the same control over and over like that: $sRemoteComputer = "asst131161" $idLabel = GUICtrlCreateLabel("Machine is Online, Waiting for Shutdown", 10, 30) Run("cmd.exe /k" & "shutdown -r -m \\" & $sRemoteComputer & " -t 3 -f", "", @SW_HIDE) While Ping($sRemoteComputer) GUICtrlSetData($idLabel, "Machine is Online, shuting down...") WEnd While Not Ping($sRemoteComputer) GUICtrlSetData($idLabel, "Machine is Offline, rebooting...") WEnd GUICtrlSetData($idLabel, "Machine is back Online, reboot complete.") Thanks for the advice, works a treat.....
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