亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁(yè) > 編程 > VBScript > 正文

Restart.vbs源代碼可以重啟遠(yuǎn)程電腦的vbs

2020-03-24 19:23:46
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:
'********************************************************************
'*
'* 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 html' target='_blank'>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 *
'* *
'********************************************************************
html教程

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

午夜精品久久久久久久99热| 国产麻豆一区二区三区精品| 人妻 日韩 欧美 综合 制服| 91久久精品美女| 成人爽a毛片免费啪啪红桃视频| 污污内射在线观看一区二区少妇| 久久久久久在线观看| 天天干视频在线观看| 成年网址网站在线观看| 亚洲视频精选在线| 香蕉久久一区二区不卡无毒影院| 男人日女人逼逼| 欧美丰满少妇人妻精品| 97成人在线视频| 欧美电影院免费观看| 欧美日韩不卡中文字幕在线| 宅男噜噜噜66一区二区| 久久久91精品| 黄色的电影在线-骚虎影院-骚虎视频| 在线观看免费不卡av| 18国产精品| 欧美肥婆姓交大片| 丝袜连裤袜欧美激情日韩| 91香蕉网站| 精品国产123区| 日日干天夜夜| 欧美高清一区二区| www.操操| 国产欧美日韩精品a在线观看| 日皮视频在线免费观看| av网址在线| 日韩国产在线观看| 欧美系列一区| 精品国产乱码久久久久久天美| 黄污网站在线观看| eeuss影院www在线观看手机| 99久久精品免费看国产| 色综合色综合| 国内精品久久久久久久影视简单| 国内精品模特av私拍在线观看| 国产中文字幕在线看| 26uuu久久噜噜噜噜| 黄色免费视频| 亚洲熟女www一区二区三区| 91sp网站在线观看入口| 中文字幕资源网在线观看免费| 欧美人与动牲交xxxxbbbb| 天堂网中文在线观看| 成人在线免费公开观看视频| 国产日韩精品在线观看| 亚洲天堂av高清| 天天综合网日韩| 亚洲在线视频网站| 欧美成人全部免费| 亚洲一区国产一区| 老少交欧美另类| 亚洲天堂2016| 黄色在线播放| 国产激情综合| 一区二区三区久久精品| 日韩毛片无码永久免费看| 视频二区在线观看| 日韩av懂色| 精品一区国产| 欧美日韩精品三区| 樱花草国产18久久久久| 在线一区欧美| 丰满少妇一级片| 日韩在线播放av| 欧美激情无毛| 成人激情免费网站| 亚洲国产美国国产综合一区二区| 欧美性xxxx在线播放| 日韩中文字幕在线视频播放| 亚洲精品国产片| 中文字幕亚洲一区二区三区五十路| 日本一区二区三区在线观看| 国产亚洲激情视频在线| 神马电影在线观看| 国产精品美女呻吟| 日本在线不卡一区二区| 亚欧洲精品视频在线观看| 欧美日韩一区中文字幕| 日韩网站免费观看高清| 国产精品视频不卡| 欧洲国产伦久久久久久久| 密臀av一区二区三区| 国精产品一区一区三区视频| 日本99精品| 中文字幕一区二区三区精彩视频| 欧美精品一二三四区| sm捆绑调教国产免费网站在线观看| 成人国产一区二区三区精品| 久久电影在线| xxxx另类黑人| 黄色在线免费观看大全| 成人免费毛片在线观看| av高清不卡在线| 久久99精品久久久| 国产精品日本一区二区不卡视频| 青青久久av北条麻妃海外网| 激情六月综合| 国产对白在线正在播放| 7m精品福利视频导航| 国产性xxxx18免费观看视频| 在线观看国产精品一区| 香蕉成人久久| 国产精品午夜在线观看| 麻豆tv在线观看| 日韩经典中文字幕一区| 91国产在线精品| 日日噜噜噜噜人人爽亚洲精品| 日本精品视频一区| 91福利国产精品| 中文字幕免费精品一区高清| 蜜桃传媒在线观看免费进入| 欧美精品中文字幕一区二区| yourporn在线观看中文站| 亚洲欧美日本一区| 欧美一区二区三区视频在线观看| 亚洲综合av影视| 欧美三级中文字幕| 中文字幕在线一| 青青青国产在线观看| 亚洲国产精品资源| 日韩免费黄色片| 亚洲永久免费网站| 老鸭窝毛片一区二区三区| 狠狠色henhense| 日本精品一区二区三区高清| 亚洲精品手机在线观看| 奇米影视888狠狠狠| 黄色网页网址在线免费| 91国产福利在线| 精品中文字幕人| 一级毛片高清视频| 日韩av网站电影| 麻豆精品99| 日韩欧美亚洲范冰冰与中字| 国产网站欧美日韩免费精品在线观看| 日韩大胆视频| 国产福利资源一区| 99热这里只有精品4| 在线播放一级片| 1插菊花综合| 亚洲欧美在线成人| 视频一区二区三区在线| 精品国产乱码久久久久夜深人妻| 婷婷夜色潮精品综合在线| 女王人厕视频2ⅴk| 天堂8在线天堂资源bt| 亚洲视频图片小说| 亚洲18女电影在线观看| 欧美精品激情blacked18| 神马电影网我不卡| 鲁鲁狠狠狠7777一区二区| 91视频最新网址| 在线免费观看不卡av| 久久精品视频一区二区三区| 中文字幕av亚洲精品一部二部| 成人午夜激情免费视频| 奶水喷射视频一区| 国产精品免费看久久久无码| 国产精品一区二区三区在线观| 欧美一区2区视频在线观看| 亚洲第一区中文99精品| 午夜不卡av免费| 成人在线免费观看av| 久久精品麻豆| 91精品国产乱码久久久久久| 国产精品入口麻豆原神| 欧美 日韩 亚洲 一区| 国产精品久久久久久久久电影网| 美女把尿口扒开给男人桶视频| 日韩在线影视| 妞干网在线视频| 亚洲激情在线观看视频免费| 色网站在线播放| 九九久久精品这里久久网| 欧美精品一区二区三区很污很色的| 色悠久久久久综合先锋影音下载| 日本不卡视频在线观看| 久久伊人成人网| 中文字幕有码在线| 亚洲欧美中文另类| 妖精视频在线观看免费| 一区二区的视频| 亚洲国产精品久久久久秋霞影院| 最近2019中文字幕大全第二页| 好看的日韩av电影| 中日韩高清电影网| 一本在线免费视频| 欧美永久精品| 国产视频青青| jizzjizz日本少妇| 国产精品白丝jk白祙| 第一福利永久视频精品| 性高潮久久久久久久| 夜夜夜久久久| 在线电影一区| 亚洲一区二区在线观看视频| 久久五月婷婷丁香社区| 中文国产一区| 99久久人妻无码精品系列| 久久精品人成| 免费精品视频一区| 97影视大全免费追剧大全在线观看| 国产永久免费| av欧美精品.com| 乱子伦视频在线看| 国产农村妇女精品一二区| 精品国产一区二区三区不卡| 亚洲大片免费看| 琪琪第一精品导航| 成人亚洲欧美一区二区三区| 美女精品一区二区| 在线观看av片| 久久精品二区三区| www.黄色片| 日本黄色免费网址| 免费在线a视频| 欧洲亚洲成人| 国产亚洲精品网站| 黄色av一区二区| 欧美一区永久视频免费观看| 国产h色视频在线观看| 中文字幕伦av一区二区邻居| 99精品欧美一区二区| 国产成人短视频| 5858s免费视频成人| 在线免费观看视频黄| 韩日三级av| 久久久国产精品免费| 欧美zozo另类异族| 国产传媒一区二区三区| 国产成人精品一区二| 欧美日韩在线第一页| 在线观看精品自拍视频| 99riav在线| 激情五月婷婷基地| 开心激情五月网| 国产亚洲观看| 亚洲激情一区| 91精品国产综合久久福利| 善良的小姨在线| 视频一区视频二区国产精品| 欧美日韩精品免费观看视频完整| 色视频成人在线观看免| 午夜视频在线观看免费视频| 国产激情91久久精品导航| 国产成人调教视频在线观看| 久久综合图片| 26uuu另类欧美| 69堂免费视频| www.com.av| 亚洲高清资源综合久久精品| 北条麻妃在线观看| 日韩一级黄色大片| 懂色av粉嫩av蜜臀av| 国产ts人妖一区二区三区| 国产一区二区视频在线免费观看| 日本不卡视频一区二区| 日韩精品在线影院| 97视频在线免费| 国产肥老妇视频| 欧美最猛性xxxx高清| 视频在线观看免费高清| 无码人妻精品一区二区50| 已婚少妇美妙人妻系列| 亚洲男人第一av网站| jizzjizzwww| 国产免费一区二区三区四在线播放| 日本女优在线视频一区二区| 日本三级电影在线看| 精品国产一区二区三区成人影院| 娇妻被老王脔到高潮失禁视频| 久久看片网站| 亚洲美女视频网| 蜜桃视频成人在线观看| 欧美a视频在线观看| 免费av中文字幕| 高清在线观看免费韩剧| 97超碰最新| 国产成人在线观看网站| 国内精品露脸在线视频播放| 精品国产欧美一区二区三区成人| 国产精品一站二站| 国产农村妇女精品久久| 国产精彩视频在线观看| 国产精品18久久久久久久久久久久| 亚洲av成人精品一区二区三区| 中文字幕亚洲一区二区三区| 欧美电影院免费观看| 国模精品视频| 国产高清在线观看免费不卡| 一区福利视频| 男插女视频网站| 日韩精品视频无播放器在线看| 免费国产在线观看| 成人va天堂| 国产精品乱人伦一区二区| 久久人人爽av| 欧美 日韩 激情| 久久久国产精品x99av| 久热精品视频在线观看一区| 熟女高潮一区二区三区| 亚洲精华国产精华精华液网站| 91精品国产色综合久久不卡蜜臀| 日韩一区二区三免费高清| 日本小视频网站| 欧美肉体xxxx裸体137大胆| 色偷偷777| 成人97在线观看视频| 日韩激情av在线免费观看| 蜜臀久久99精品久久久久久| 97aⅴ精品视频一二三区| 久久久久久激情| 日韩一区三区| 丁香婷婷久久| 中文字幕制服丝袜成人av| 国产在线一区二| 91最新在线免费观看| 欧美激情一级欧美精品| 久久成人精品一区二区三区| 97精品人妻一区二区三区香蕉| 成年人免费观看视频网站| 精品久久久久国产| 国产专区视频|