Passing Command Line Arguments
'==========================================================================
' NAME: Arguments01.vbs
' AUTHOR: Neal Walters
' http://VBScript-Training.com
'==========================================================================
Option Explicit
Dim strFilename, strCommand
strFilename = WScript.Arguments(0)
strCommand = ucase(WScript.Arguments(1))
'validate input parameters
If strCommand <> "COPY" And strCommand <> "MOVE" Then
WScript.Echo "This program requires two arguments: " & VbCrLf & _
"CScript Arguments01.vbs filename cmd " & VbCrLf & _
" where cmd must be 'MOVE' or 'COPY'. "
WScript.Echo
End If
WScript.Echo "Filename=" & strFilename
WScript.Echo "Command=" & strCommand
'==========================================================================
' NAME: Arguments02.vbs
' AUTHOR: Neal Walters
' http://VBScript-Training.com
'==========================================================================
For j = 0 To WScript.Arguments.Count - 1
WScript.Echo "j=" & j & " Argument=" & WScript.Arguments(j)
Next
|