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_POWEROFF)
Else
intStatus = objInstance.Win32ShutDown(CONST_POWEROFF)
End If
IF intStatus = 0 Then
strMessage = "Power off machine " & strServer & "."
Else
strMessage = "Failed to power off machine " & strServer & "."
End If
Call WriteLine(strMessage,objOutputFile)
Next
If IsObject(objOutputFile) Then
objOutputFile.Close
Call Wscript.Echo ("Results are saved in file " & strOutputFile & ".")
End If
End Sub
'********************************************************************
'*
'* Sub Shutdown()
'*
'* Purpose: Shutsdown a machine.
'*
'* Input: strServer a machine name
'* strOutputFile an output file name
'* strUserName the current user's name
'* strPassword the current user's password
'* blnForce specifies whether to force the logoff
'* intTimer specifies the amount of time to perform the function
'*
'* Output: Results are either printed on screen or saved in strOutputFile.
'*
'********************************************************************
Private Sub Shutdown(strServer, strOutputFile, strUserName, strPassword, blnShutDown, blnForce, intTimer)







