Jump to content

Reboot Monitor


Recommended Posts

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...

Link to comment
Share on other sites

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.")

:mellow:

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
Link to comment
Share on other sites

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.")

:P

Thanks for the advice, works a treat..... :mellow:
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...