婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Restart.vbs源代碼可以重啟遠程電腦的vbs

Restart.vbs源代碼可以重啟遠程電腦的vbs

熱門標簽:地圖標注都什么意思 龍族幻想白銀異聞天使地圖標注 琿春電子地圖標注 鴿森地圖標注 菏澤電銷機器人管理軟件 福建外呼系統購買 百度地圖標注的位置怎么更改 聯通能辦理400電話是多少錢 福建醫療智能外呼系統哪家好
復制代碼 代碼如下:

'********************************************************************
'*
'* File:           Restart.vbs
'* Created:        March 1999
'* Version:        1.0
'*
'*  Main Function:  Shutsdown, PowerOff, LogOff, Restarts a machine.
'*
'*  Restart.vbs    /S server> [/U username>] [/W password>] 
'*                 [/O outputfile>] [/L} [/P] [/R] [/Q] [/F] [/T time in seconds>]
'*
'* Copyright (C) 1999 Microsoft Corporation
'*
'********************************************************************

OPTION EXPLICIT

    'Define constants
    CONST CONST_ERROR                   = 0
    CONST CONST_WSCRIPT                 = 1
    CONST CONST_CSCRIPT                 = 2
    CONST CONST_SHOW_USAGE              = 3
    CONST CONST_PROCEED                 = 4

    'Shutdown Method Constants
    CONST CONST_SHUTDOWN                = 1
    CONST CONST_LOGOFF                  = 0
    CONST CONST_POWEROFF                = 8
    CONST CONST_REBOOT                  = 2
    CONST CONST_FORCE_REBOOT            = 6
    CONST CONST_FORCE_POWEROFF          = 12
    CONST CONST_FORCE_LOGOFF            = 4
    CONST CONST_FORCE_SHUTDOWN          = 5

    'Declare variables
    Dim intOpMode, i
    Dim strServer, strUserName, strPassword, strOutputFile
    Dim blnLogoff, blnPowerOff, blnReBoot, blnShutDown
    Dim blnForce
    Dim intTimer
    Dim UserArray(3)
    Dim MyCount

    'Make sure the host is csript, if not then abort
    VerifyHostIsCscript()

    'Parse the command line
    intOpMode = intParseCmdLine(strServer     ,  _
                                strUserName   ,  _
                                strPassword   ,  _
                                strOutputFile ,  _
                                blnLogoff     ,  _
                                blnPowerOff   ,  _
                                blnReBoot     ,  _
                                blnShutdown   ,  _
                                blnForce      ,  _
                                intTimer         )

    Select Case intOpMode

        Case CONST_SHOW_USAGE
            Call ShowUsage()

        Case CONST_PROCEED                 
            Call Reboot(strServer     , _
                          strOutputFile , _
                          strUserName   , _
                          strPassword   , _
                          blnReboot     , _
                          blnForce      , _
                          intTimer        )

            Call LogOff(strServer     , _
                          strOutputFile , _
                          strUserName   , _
                          strPassword   , _
                          blnLogoff     , _
                          blnForce      , _
                          intTimer        )

            Call PowerOff(strServer     , _
                          strOutputFile , _
                          strUserName   , _
                          strPassword   , _
                          blnPowerOff   , _
                          blnForce      , _
                          intTimer        )

            Call ShutDown(strServer     , _
                          strOutputFile , _
                          strUserName   , _
                          strPassword   , _
                          blnShutDown   , _
                          blnForce      , _
                          intTimer        )

        Case CONST_ERROR
            'Do Nothing

        Case Else                    'Default -- should never happen
            Call Wscript.Echo("Error occurred in passing parameters.")

    End Select


'********************************************************************
'*
'* Sub Reboot()
'*
'* Purpose: Reboots 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 Reboot(strServer, strOutputFile, strUserName, strPassword, blnReboot, blnForce, intTimer)


    ON ERROR RESUME NEXT

    Dim objFileSystem, objOutputFile, objService, objEnumerator, objInstance
    Dim strQuery, strMessage
    Dim intStatus
    ReDim strID(0), strName(0)

    if blnreboot = false then
         Exit Sub
    End if

    if intTimer > 0 then
        wscript.echo "Rebooting machine "  strServer  " in "  intTimer  " seconds..."
        wscript.sleep (intTimer * 1000)
    End if

    'Open a text file for output if the file is requested
    If Not IsEmpty(strOutputFile) Then
        If (NOT blnOpenFile(strOutputFile, objOutputFile)) Then
            Call Wscript.Echo ("Could not open an output file.")
            Exit Sub
        End If
    End If

    'Establish a connection with the server.
    If blnConnect("root\cimv2" , _
                   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

    If IsObject(objOutputFile) Then
        objOutputFile.Close
        Call Wscript.Echo ("Results are saved in file "  strOutputFile  ".")
    End If
End Sub


'********************************************************************
'*
'* Sub LogOff()
'*
'* Purpose: Logs off the user currently logged onto 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 preform the function
'*
'* Output:  Results are either printed on screen or saved in strOutputFile.
'*
'********************************************************************
Private Sub LogOff(strServer, strOutputFile, strUserName, strPassword, blnLogoff, blnForce, intTimer)


    ON ERROR RESUME NEXT

    Dim objFileSystem, objOutputFile, objService, objEnumerator, objInstance
    Dim strQuery, strMessage
    Dim intStatus
    ReDim strID(0), strName(0)

     If blnlogoff = false then
          Exit Sub
     End if

    if intTimer > 1 then 
     wscript.echo "Logging off machine "  strServer  " in "  intTimer  " seconds..."
        wscript.sleep (intTimer * 1000)
    End if

    'Open a text file for output if the file is requested
    If Not IsEmpty(strOutputFile) Then
        If (NOT blnOpenFile(strOutputFile, objOutputFile)) Then
            Call Wscript.Echo ("Could not open an output file.")
            Exit Sub
        End If
    End If

    'Establish a connection with the server.
    If blnConnect("root\cimv2" , _
                   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_LOGOFF)
        Else
            intStatus = objInstance.Win32ShutDown(CONST_LOGOFF)
        End If

        IF intStatus = 0 Then
            strMessage = "Logging off the current user on machine "  _
                         strServer  "..."
        Else
            strMessage = "Failed to log off the current user from 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 PowerOff()
'*
'* Purpose: Powers off 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 PowerOff(strServer, strOutputFile, strUserName, strPassword, blnPowerOff, blnForce, intTimer)


    ON ERROR RESUME NEXT

    Dim objFileSystem, objOutputFile, objService, objEnumerator, objInstance
    Dim strQuery, strMessage
    Dim intStatus
    ReDim strID(0), strName(0)

      if blnPoweroff = false then
             Exit sub
      End if

    If intTimer > 0 then     
        wscript.echo "Powering off machine "  strServer  " in "  intTimer  " seconds..."
    wscript.sleep (intTimer * 1000)
    End if

    'Open a text file for output if the file is requested
    If Not IsEmpty(strOutputFile) Then
        If (NOT blnOpenFile(strOutputFile, objOutputFile)) Then
            Call Wscript.Echo ("Could not open an output file.")
            Exit Sub
        End If
    End If

    'Establish a connection with the server.
    If blnConnect("root\cimv2" , _
                   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_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)


    ON ERROR RESUME NEXT

    Dim objFileSystem, objOutputFile, objService, objEnumerator, objInstance
    Dim strQuery, strMessage
    Dim intStatus
    ReDim strID(0), strName(0)

    If blnShutdown = False then
          Exit Sub
    End if   

    if intTimer > 0 then 
              wscript.echo "Shutting down computer "  strServer  " in "  intTimer  " seconds..."
         wscript.sleep (intTimer * 1000)
    End if


    'Open a text file for output if the file is requested
    If Not IsEmpty(strOutputFile) Then
        If (NOT blnOpenFile(strOutputFile, objOutputFile)) Then
            Call Wscript.Echo ("Could not open an output file.")
            Exit Sub
        End If
    End If

    'Establish a connection with the server.
    If blnConnect("root\cimv2" , _
                   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_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          )


    ON ERROR RESUME NEXT

    Dim strFlag
    Dim intState, intArgIter
    Dim objFileSystem

    If Wscript.Arguments.Count > 0 Then
        strFlag = Wscript.arguments.Item(0)
    End If

    If IsEmpty(strFlag) Then                'No arguments have been received
        Wscript.Echo("Arguments are Required.")
        intParseCmdLine = CONST_ERROR
        Exit Function
    End If

    'Check if the user is asking for help or is just confused
    If (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _
        OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "?") _ 
        OR (strFlag="h") Then
        intParseCmdLine = CONST_SHOW_USAGE
        Exit Function
    End If

    'Retrieve the command line and set appropriate variables
     intArgIter = 0
    Do While intArgIter = Wscript.arguments.Count - 1
        Select Case Left(LCase(Wscript.arguments.Item(intArgIter)),2)

            Case "/s"
                intParseCmdLine = CONST_PROCEED
                If Not blnGetArg("Server", strServer, intArgIter) Then
                    intParseCmdLine = CONST_ERROR
                    Exit Function
                End If
                intArgIter = intArgIter + 1

            Case "/o"
                If Not blnGetArg("Output File", strOutputFile, intArgIter) Then
                    intParseCmdLine = CONST_ERROR
                    Exit Function
                End If
                intArgIter = intArgIter + 1

            Case "/u"
                If Not blnGetArg("User Name", strUserName, intArgIter) Then
                    intParseCmdLine = CONST_ERROR
                    Exit Function
                End If
                intArgIter = intArgIter + 1

            Case "/w"
                If Not blnGetArg("User Password", strPassword, intArgIter) Then
                    intParseCmdLine = CONST_ERROR
                    Exit Function
                End If
                intArgIter = intArgIter + 1

            Case "/f"
                blnForce = True
                intArgIter = intArgIter + 1

            Case "/r"
                blnReBoot = True
                userarray(0) = blnReBoot
                intArgIter = intArgIter + 1

            Case "/q"
                blnPowerOff = True
                userarray(1) = blnPowerOff
                intArgIter = intArgIter + 1

            Case "/l"
                blnLogOff = True
                userarray(2) = blnLogoff
                intArgIter = intArgIter + 1

            Case "/p"
                blnShutDown = True
                userarray(3) = blnShutDown
                intArgIter = intArgIter + 1

            Case "/t"
                If Not blnGetArg("Timer", intTimer, intArgIter) Then
                    intParseCmdLine = CONST_ERROR
                    Exit Function
                End If
                intArgIter = intArgIter + 1

            Case Else 'We shouldn't get here
                Call Wscript.Echo("Invalid or misplaced parameter: " _
                    Wscript.arguments.Item(intArgIter)  vbCRLF _
                    "Please check the input and try again,"  vbCRLF _
                    "or invoke with '/?' for help with the syntax.")
                Wscript.Quit

        End Select

    Loop '** intArgIter = Wscript.arguments.Count - 1

    MyCount = 0

    for i = 0 to 3
        if userarray(i) = True then
            MyCount = Mycount + 1
        End if
    Next

   if Mycount > 1 then 
        intParseCmdLine = CONST_SHOW_USAGE
   End if

    If IsEmpty(intParseCmdLine) Then 
        intParseCmdLine = CONST_ERROR
        Wscript.Echo("Arguments are Required.")
    End If

End Function

'********************************************************************
'*
'* Sub ShowUsage()
'*
'* Purpose: Shows the correct usage to the user.
'*
'* Input:   None
'*
'* Output:  Help messages are displayed on screen.
'*
'********************************************************************
Private Sub ShowUsage()

    Wscript.Echo ""
    Wscript.Echo "Logoffs, Reboots, Powers Off, or Shuts Down a machine."
    Wscript.Echo ""
    Wscript.Echo "SYNTAX:"
    Wscript.Echo "  Restart.vbs [/S server>] [/U username>] [/W password>]"
    Wscript.Echo "              [/O outputfile>] /L> /R> /P> /Q> /F> [/T time in seconds>]"
    Wscript.Echo ""
    Wscript.Echo "PARAMETER SPECIFIERS:"
    wscript.echo "   /T            Amount of time to perform the function."
    Wscript.Echo "   /Q            Perform Shutdown."
    Wscript.Echo "   /P            Perform Poweroff."
    Wscript.Echo "   /R            Perform Reboot."
    Wscript.Echo "   /L            Perform Logoff."
    Wscript.Echo "   /F            Force Function."
    Wscript.Echo "   server        A machine name."
    Wscript.Echo "   username      The current user's name."
    Wscript.Echo "   password      Password of the current user."
    Wscript.Echo "   outputfile    The output file name."
    Wscript.Echo ""
    Wscript.Echo "EXAMPLE:"
    Wscript.Echo "1. cscript Restart.vbs /S MyMachine2 /R"
    Wscript.Echo "   Reboots the current machine MyMachine2."
    Wscript.Echo "2. cscript Restart.vbs /S MyMachine2 /R /F"
    Wscript.Echo "   Forces MyMachine2 to reboot."
    Wscript.Echo "3. cscript Restart.vbs /S MyMachine2 /R /T 30"
    Wscript.Echo "   Reboots the current machine MyMachine2 in 30 seconds."
    Wscript.Echo "NOTE:"
    Wscript.Echo "   The force option will make the machine perform the function even " _
                "if there are"
    Wscript.Echo "   open and unsaved docuements on the screen."

End Sub

'********************************************************************
'* General Routines
'********************************************************************

'********************************************************************
'*
'* Function strPackString()
'*
'* Purpose: Attaches spaces to a string to increase the length to intWidth.
'*
'* Input:   strString   a string
'*          intWidth    the intended length of the string
'*          blnAfter    Should spaces be added after the string?
'*          blnTruncate specifies whether to truncate the string or not if
'*                      the string length is longer than intWidth
'*
'* Output:  strPackString is returned as the packed string.
'*
'********************************************************************
Private Function strPackString( ByVal strString, _
                                ByVal intWidth,  _
                                ByVal blnAfter,  _
                                ByVal blnTruncate)

    ON ERROR RESUME NEXT

    intWidth      = CInt(intWidth)
    blnAfter      = CBool(blnAfter)
    blnTruncate   = CBool(blnTruncate)

    If Err.Number Then
        Call Wscript.Echo ("Argument type is incorrect!")
        Err.Clear
        Wscript.Quit
    End If

    If IsNull(strString) Then
        strPackString = "null"  Space(intWidth-4)
        Exit Function
    End If

    strString = CStr(strString)
    If Err.Number Then
        Call Wscript.Echo ("Argument type is incorrect!")
        Err.Clear
        Wscript.Quit
    End If

    If intWidth > Len(strString) Then
        If blnAfter Then
            strPackString = strString  Space(intWidth-Len(strString))
        Else
            strPackString = Space(intWidth-Len(strString))  strString  " "
        End If
    Else
        If blnTruncate Then
            strPackString = Left(strString, intWidth-1)  " "
        Else
            strPackString = strString  " "
        End If
    End If

End Function

'********************************************************************
'* 
'*  Function blnGetArg()
'*
'*  Purpose: Helper to intParseCmdLine()
'* 
'*  Usage:
'*
'*     Case "/s" 
'*       blnGetArg ("server name", strServer, intArgIter)
'*
'********************************************************************
Private Function blnGetArg ( ByVal StrVarName,   _
                             ByRef strVar,       _
                             ByRef intArgIter) 

    blnGetArg = False 'failure, changed to True upon successful completion

    If Len(Wscript.Arguments(intArgIter)) > 2 then
        If Mid(Wscript.Arguments(intArgIter),3,1) = ":" then
            If Len(Wscript.Arguments(intArgIter)) > 3 then
                strVar = Right(Wscript.Arguments(intArgIter), _
                         Len(Wscript.Arguments(intArgIter)) - 3)
                blnGetArg = True
                Exit Function
            Else
                intArgIter = intArgIter + 1
                If intArgIter > (Wscript.Arguments.Count - 1) Then
                    Call Wscript.Echo( "Invalid "  StrVarName  ".")
                    Call Wscript.Echo( "Please check the input and try again.")
                    Exit Function
                End If

                strVar = Wscript.Arguments.Item(intArgIter)
                If Err.Number Then
                    Call Wscript.Echo( "Invalid "  StrVarName  ".")
                    Call Wscript.Echo( "Please check the input and try again.")
                    Exit Function
                End If

                If InStr(strVar, "/") Then
                    Call Wscript.Echo( "Invalid "  StrVarName)
                    Call Wscript.Echo( "Please check the input and try again.")
                    Exit Function
                End If

                blnGetArg = True 'success
            End If
        Else
            strVar = Right(Wscript.Arguments(intArgIter), _
                     Len(Wscript.Arguments(intArgIter)) - 2)
            blnGetArg = True 'success
            Exit Function
        End If
    Else
        intArgIter = intArgIter + 1
        If intArgIter > (Wscript.Arguments.Count - 1) Then
            Call Wscript.Echo( "Invalid "  StrVarName  ".")
            Call Wscript.Echo( "Please check the input and try again.")
            Exit Function
        End If

        strVar = Wscript.Arguments.Item(intArgIter)
        If Err.Number Then
            Call Wscript.Echo( "Invalid "  StrVarName  ".")
            Call Wscript.Echo( "Please check the input and try again.")
            Exit Function
        End If

        If InStr(strVar, "/") Then
            Call Wscript.Echo( "Invalid "  StrVarName)
            Call Wscript.Echo( "Please check the input and try again.")
            Exit Function
        End If
        blnGetArg = True 'success
    End If
End Function

'********************************************************************
'*
'* Function blnConnect()
'*
'* Purpose: Connects to machine strServer.
'*
'* Input:   strServer       a machine name
'*          strNameSpace    a namespace
'*          strUserName     name of the current user
'*          strPassword     password of the current user
'*
'* Output:  objService is returned  as a service object.
'*          strServer is set to local host if left unspecified
'*
'********************************************************************
Private Function blnConnect(ByVal strNameSpace, _
                            ByVal strUserName,  _
                            ByVal strPassword,  _
                            ByRef strServer,    _
                            ByRef objService)

    ON ERROR RESUME NEXT

    Dim objLocator, objWshNet

    blnConnect = False     'There is no error.

    'Create Locator object to connect to remote CIM object manager
    Set objLocator = CreateObject("WbemScripting.SWbemLocator")
    If Err.Number then
        Call Wscript.Echo( "Error 0x"  CStr(Hex(Err.Number))  _
                           " occurred in creating a locator object." )
        If Err.Description > "" Then
            Call Wscript.Echo( "Error description: "  Err.Description  "." )
        End If
        Err.Clear
        blnConnect = True     'An error occurred
        Exit Function
    End If

    'Connect to the namespace which is either local or remote
    Set objService = objLocator.ConnectServer (strServer, strNameSpace, _
       strUserName, strPassword)
    ObjService.Security_.impersonationlevel = 3
    If Err.Number then
        Call Wscript.Echo( "Error 0x"  CStr(Hex(Err.Number))  _
                           " occurred in connecting to server " _
            strServer  ".")
        If Err.Description > "" Then
            Call Wscript.Echo( "Error description: "  Err.Description  "." )
        End If
        Err.Clear
        blnConnect = True     'An error occurred
    End If

    'Get the current server's name if left unspecified
    If IsEmpty(strServer) Then
        Set objWshNet = CreateObject("Wscript.Network")
    strServer     = objWshNet.ComputerName
    End If

End Function

'********************************************************************
'*
'* Sub      VerifyHostIsCscript()
'*
'* Purpose: Determines which program is used to run this script.
'*
'* Input:   None
'*
'* Output:  If host is not cscript, then an error message is printed 
'*          and the script is aborted.
'*
'********************************************************************
Sub VerifyHostIsCscript()

    ON ERROR RESUME NEXT

    Dim strFullName, strCommand, i, j, intStatus

    strFullName = WScript.FullName

    If Err.Number then
        Call Wscript.Echo( "Error 0x"  CStr(Hex(Err.Number))  " occurred." )
        If Err.Description > "" Then
            Call Wscript.Echo( "Error description: "  Err.Description  "." )
        End If
        intStatus =  CONST_ERROR
    End If

    i = InStr(1, strFullName, ".exe", 1)
    If i = 0 Then
        intStatus =  CONST_ERROR
    Else
        j = InStrRev(strFullName, "\", i, 1)
        If j = 0 Then
            intStatus =  CONST_ERROR
        Else
            strCommand = Mid(strFullName, j+1, i-j-1)
            Select Case LCase(strCommand)
                Case "cscript"
                    intStatus = CONST_CSCRIPT
                Case "wscript"
                    intStatus = CONST_WSCRIPT
                Case Else       'should never happen
                    Call Wscript.Echo( "An unexpected program was used to " _
                                        "run this script." )
                    Call Wscript.Echo( "Only CScript.Exe or WScript.Exe can " _
                                        "be used to run this script." )
                    intStatus = CONST_ERROR
                End Select
        End If
    End If

    If intStatus > CONST_CSCRIPT Then
        Call WScript.Echo( "Please run this script using CScript."  vbCRLF  _
             "This can be achieved by"  vbCRLF  _
             "1. Using ""CScript Restart.vbs arguments"" for Windows 95/98 or" _
              vbCRLF  "2. Changing the default Windows Scripting Host " _
              "setting to CScript"  vbCRLF  "    using ""CScript " _
              "http://H:CScript //S"" and running the script using"  vbCRLF  _
             "    ""Restart.vbs arguments"" for Windows NT/2000." )
        WScript.Quit
    End If

End Sub

'********************************************************************
'*
'* Sub WriteLine()
'* Purpose: Writes a text line either to a file or on screen.
'* Input:   strMessage  the string to print
'*          objFile     an output file object
'* Output:  strMessage is either displayed on screen or written to a file.
'*
'********************************************************************
Sub WriteLine(ByVal strMessage, ByVal objFile)

    On Error Resume Next
    If IsObject(objFile) then        'objFile should be a file object
        objFile.WriteLine strMessage
    Else
        Call Wscript.Echo( strMessage )
    End If

End Sub

'********************************************************************
'* 
'* Function blnErrorOccurred()
'*
'* Purpose: Reports error with a string saying what the error occurred in.
'*
'* Input:   strIn        string saying what the error occurred in.
'*
'* Output:  displayed on screen 
'* 
'********************************************************************
Private Function blnErrorOccurred (ByVal strIn)

    If Err.Number Then
        Call Wscript.Echo( "Error 0x"  CStr(Hex(Err.Number))  ": "  strIn)
        If Err.Description > "" Then
            Call Wscript.Echo( "Error description: "  Err.Description)
        End If
        Err.Clear
        blnErrorOccurred = True
    Else
        blnErrorOccurred = False
    End If

End Function

'********************************************************************
'* 
'* Function blnOpenFile
'*
'* Purpose: Opens a file.
'*
'* Input:   strFileName        A string with the name of the file.
'*
'* Output:  Sets objOpenFile to a FileSystemObject and setis it to 
'*            Nothing upon Failure.
'* 
'********************************************************************
Private Function blnOpenFile(ByVal strFileName, ByRef objOpenFile)

    ON ERROR RESUME NEXT

    Dim objFileSystem

    Set objFileSystem = Nothing

    If IsEmpty(strFileName) OR strFileName = "" Then
        blnOpenFile = False
        Set objOpenFile = Nothing
        Exit Function
    End If

    'Create a file object
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    If blnErrorOccurred("Could not create filesystem object.") Then
        blnOpenFile = False
        Set objOpenFile = Nothing
        Exit Function
    End If

    'Open the file for output
    Set objOpenFile = objFileSystem.OpenTextFile(strFileName, 8, True)
    If blnErrorOccurred("Could not open") Then
        blnOpenFile = False
        Set objOpenFile = Nothing
        Exit Function
    End If
    blnOpenFile = True

End Function

'********************************************************************
'*                                                                  *
'*                           End of File                            *
'*                                                                  *
'********************************************************************

標簽:張掖 南京 內蒙古 達州 柳州 丹東 資質掛靠 鶴壁

巨人網絡通訊聲明:本文標題《Restart.vbs源代碼可以重啟遠程電腦的vbs》,本文關鍵詞  Restart.vbs,源代碼,可以,重啟,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Restart.vbs源代碼可以重啟遠程電腦的vbs》相關的同類信息!
  • 本頁收集關于Restart.vbs源代碼可以重啟遠程電腦的vbs的相關信息資訊供網民參考!
  • 推薦文章
    婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av
    国产色产综合色产在线视频| 亚洲精品在线三区| 国产精品福利电影一区二区三区四区| 一本久道中文字幕精品亚洲嫩| 婷婷综合五月天| 综合中文字幕亚洲| 国产欧美日韩激情| 久久一夜天堂av一区二区三区 | 亚洲高清免费一级二级三级| 国产日产欧美一区二区视频| 秋霞电影一区二区| 日韩欧美黄色影院| 毛片基地黄久久久久久天堂| 欧美三级日本三级少妇99| 日本一区二区视频在线观看| 老汉av免费一区二区三区| 国产在线播放一区二区三区| 欧美日韩一区在线观看| 亚洲一二三四久久| 久久久亚洲高清| 日本高清不卡视频| 久久99精品久久久久久国产越南| 国产精品一区二区不卡| 天天综合网 天天综合色| 国产精品久久一级| 欧美日韩国产另类不卡| 懂色av一区二区三区免费看| 日本网站在线观看一区二区三区| 色综合天天天天做夜夜夜夜做| 中文字幕一区二区5566日韩| 精油按摩中文字幕久久| 一区二区三区免费| 亚洲精品中文在线观看| 亚洲天堂久久久久久久| 欧美午夜不卡视频| 欧美日韩在线播放三区| 国产成人免费视频网站| 精品夜夜嗨av一区二区三区| 夜夜爽夜夜爽精品视频| 亚洲免费观看高清完整版在线观看熊| 久久久久九九视频| 久久精品人人做人人爽97| 奇米综合一区二区三区精品视频| 日韩激情在线观看| 免费高清视频精品| 91在线视频网址| 成人免费高清在线| 国产亚洲精品bt天堂精选| 欧美第一区第二区| 国产精品久久影院| 99re热视频精品| 欧美性猛交xxxxxx富婆| 欧美一区二区在线不卡| 亚洲国产成人午夜在线一区| 日韩毛片精品高清免费| 日韩一区精品视频| 91小视频在线免费看| 精品黑人一区二区三区久久| 日韩一区日韩二区| 韩国午夜理伦三级不卡影院| 99精品国产一区二区三区不卡 | 中文在线免费一区三区高中清不卡| 亚洲欧美自拍偷拍| 日韩国产成人精品| a在线播放不卡| 精品国产乱码久久久久久牛牛| 亚洲愉拍自拍另类高清精品| 国产宾馆实践打屁股91| 日韩精品中文字幕一区二区三区 | 亚洲一区在线观看视频| 国产成人免费在线| 欧美一区二区三区性视频| 国产精品久久久久影视| 黄色日韩三级电影| 日韩欧美一区二区视频| 午夜不卡av在线| 91免费精品国自产拍在线不卡| 欧美性猛片xxxx免费看久爱| 国产精品美女久久久久久久久久久| 日韩国产欧美视频| 欧美日韩国产乱码电影| 亚洲综合久久av| 在线一区二区三区做爰视频网站| 国产女主播视频一区二区| 狠狠色综合色综合网络| 精品久久久久久久久久久久久久久 | 亚洲美女视频一区| 成人a免费在线看| 国产欧美精品在线观看| 国产一区二区福利| 精品三级在线观看| 免费看黄色91| 日韩三级视频中文字幕| 免费久久精品视频| 精品国产免费久久| 国产综合色在线| 国产清纯美女被跳蛋高潮一区二区久久w | 91丝袜高跟美女视频| 国产欧美一区二区三区鸳鸯浴 | 99久久婷婷国产综合精品电影| 日本一二三不卡| 91蜜桃视频在线| 一区二区视频在线| 欧美日韩视频在线一区二区 | 国产丝袜在线精品| 成人av在线网站| 亚洲免费在线观看视频| 欧美亚洲动漫精品| 青草av.久久免费一区| 久久中文字幕电影| av影院午夜一区| 亚洲第一在线综合网站| 欧美变态口味重另类| 懂色av一区二区三区蜜臀| 亚洲色图在线视频| 欧美肥妇free| 国产高清一区日本| 一卡二卡三卡日韩欧美| 日韩一级欧美一级| 国产成a人亚洲精品| 亚洲综合小说图片| 日韩欧美国产电影| 成人免费va视频| 亚洲国产综合在线| 久久久精品国产免大香伊| 99久久国产综合精品麻豆| 亚洲国产成人av好男人在线观看| 26uuu精品一区二区在线观看| eeuss鲁一区二区三区| 免费观看一级欧美片| 中文字幕亚洲欧美在线不卡| 7777精品久久久大香线蕉| 国产福利一区二区三区在线视频| 一区二区三区国产精品| 久久久精品国产免大香伊| 色狠狠av一区二区三区| 激情六月婷婷综合| 亚洲一区二区三区视频在线播放 | 成人激情综合网站| 日韩高清在线观看| 国产精品天天看| 欧美一二三区在线观看| 色婷婷久久综合| 福利一区二区在线| 美女国产一区二区| 亚洲成av人片一区二区梦乃| 国产日韩欧美综合一区| 91精品在线观看入口| 91在线播放网址| 国产成人99久久亚洲综合精品| 蜜臀av性久久久久蜜臀av麻豆| 亚洲精品免费一二三区| 国产精品毛片无遮挡高清| 精品少妇一区二区三区在线播放 | 中文字幕中文字幕一区二区| 91精品国产91热久久久做人人 | 91蜜桃免费观看视频| 国产白丝精品91爽爽久久| 麻豆成人av在线| 亚洲第一av色| 亚洲午夜久久久久久久久久久 | 国产激情一区二区三区四区| 亚洲福利一区二区三区| 136国产福利精品导航| 欧美极品少妇xxxxⅹ高跟鞋| 日韩欧美在线综合网| 欧美日韩国产bt| 欧美性受xxxx黑人xyx| 一本色道久久综合亚洲aⅴ蜜桃 | 国产高清视频一区| 国模无码大尺度一区二区三区| 日本不卡123| 日韩精品福利网| 日韩av在线免费观看不卡| 日韩av电影免费观看高清完整版 | 欧美精品一区二区久久婷婷| 在线综合视频播放| 欧美日韩国产综合视频在线观看| 色94色欧美sute亚洲线路一ni| 色哟哟精品一区| 在线视频欧美区| 欧美日韩午夜在线视频| 91精品黄色片免费大全| 精品人伦一区二区色婷婷| 欧美精品一区二区三区蜜臀| 久久男人中文字幕资源站| 国产欧美一区二区精品性色超碰| 国产精品你懂的| 一区二区三区欧美日韩| 日韩在线a电影| 国产精品一区久久久久| av在线播放成人| 欧美日韩精品二区第二页| 精品日韩av一区二区| 中文字幕不卡的av| 一区二区三区四区不卡在线| 午夜精品福利一区二区三区蜜桃| 蜜桃视频免费观看一区| 国产成人久久精品77777最新版本| 99久久国产综合精品女不卡|