Naveed 0 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... Share this post Link to post Share on other sites
PsaltyDS 42 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 Share this post Link to post Share on other sites
Naveed 0 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..... Share this post Link to post Share on other sites