'Establish a connection with the server.
If blnConnect("rootcimv2" , _
strUserName , _
strPassword , _
strServer , _
objService ) Then
Call Wscript.Echo("")
Call Wscript.Echo("Please check the server name, " _
& "credentials and WBEM Core.")
Exit Sub
End If
strID(0) = ""
strName(0) = ""
strMessage = ""
strQuery = "Select * From Win32_OperatingSystem"
Set objEnumerator = objService.ExecQuery(strQuery,,0)
If Err.Number Then
Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred during the query."
If Err.Description <> "" Then
Print "Error description: " & Err.Description & "."
End If
Err.Clear
Exit Sub
End If
i = 0
For Each objInstance in objEnumerator
If blnForce Then
intStatus = objInstance.Win32ShutDown(CONST_FORCE_REBOOT)
Else
intStatus = objInstance.Win32ShutDown(CONST_REBOOT)
End If
IF intStatus = 0 Then
strMessage = "Reboot a machine " & strServer & "."
Else
strMessage = "Failed to reboot a machine " & strServer & "."
End If
Call WriteLine(strMessage,objOutputFile)
Next







