Restart.vbs源代码可以重启远程电脑的vbs

2019-01-16 12:30:00刘景俊

    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_SHUTDOWN)
        Else
            intStatus = objInstance.Win32ShutDown(CONST_SHUTDOWN)
        End If

        IF intStatus = 0 Then
            strMessage = "Shuts down machine " & strServer & "."
        Else
            strMessage = "Failed to shutdown 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



'********************************************************************
'*
'* Function intParseCmdLine()
'*
'* Purpose: Parses the command line.
'* Input:   
'*
'* Output:  strServer         a remote server ("" = local server")
'*          strUserName       the current user's name
'*          strPassword       the current user's password
'*          strOutputFile     an output file name
'*          intTimer          amount of time in seconds
'*
'********************************************************************
Private Function intParseCmdLine( ByRef strServer,        _
                                  ByRef strUserName,      _
                                  ByRef strPassword,      _
                                  ByRef strOutputFile,    _
                                  ByRef blnLogoff,        _
                                  ByRef blnShutdown,      _
                                  ByRef blnReboot,        _
                                  ByRef blnPowerOff,      _
                                  ByRef blnForce,         _
                                  ByRef intTimer          )