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

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

        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."