B_Dorsey
asked on
Restart Machine?
Is it possible to write a script that checks a webpage for either an error or if it doesnt bring up anything ..etc.etc.. that it will jsut restart the machine?
Thanks
Bill D
Thanks
Bill D
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW: the above code was tested on an XP machine .... If you have trouble getting it to compile on a 2k box you may need to download and install the WMI redistributable... I'll hunt up the link in a few.
Ive been able to reduce the lines of code some more....using *.InstancesOf lets me workaround the WMI scripting Query.....
Set OSSet = GetObject("winmgmts:{imper sonationLe vel=impers onate,(Shu tdown)}"). InstancesO f("Win32_O peratingSy stem")
For Each System In OSSet
System.Shutdown
Next
Set OSSet = GetObject("winmgmts:{imper
For Each System In OSSet
System.Shutdown
Next
ASKER
Thanks mccainz2
It shuts down, now I just gotta get it to do it when I want it too.
Thanks again
Bill D
It shuts down, now I just gotta get it to do it when I want it too.
Thanks again
Bill D
the following will restart the machine , works (with minor mods in VB and VB script)
Private Sub Command1_Click()
Set OpSysSet = GetObject("winmgmts:{imper
"//./root/cimv2").ExecQuer
"Win32_OperatingSystem WHERE Primary = true")
ianswer = MsgBox("Shut Down Windows? -Warning- Save data first!", _
vbQuestion + vbOKCancel, _
"Shut Down")
If ianswer = vbOK Then 'If OK, shut down
For Each OpSys In OpSysSet
outParam = OpSys.Shutdown
If Err.Number <> 0 Then
WScript.echo "Error number: " & Err.Number & _
vbNewLine & _
"Description: " & Err.Description
End If
Next
Else ' user selected cancel
MsgBox "Operation canceled"
End If
End Sub