Arguments - VBScript
Arguments
The Arguments
object provides access to command-line arguments passed to a VB Script. It is an indexed collection, with each element representing one argument.
Syntax
Dim args As Arguments
Options
None
Examples
Simple Usage
Dim x
x = Arguments(1)
WScript.Echo "The first argument is " & x
Looping Through Arguments
Dim x
For Each x In Arguments
WScript.Echo x
Next
Common Issues
Argument Index Out of Range
Make sure the argument index specified is within the range of valid arguments. Use the Arguments.Count
property to determine the number of arguments available.
Integration
The Arguments
object can be used in conjunction with other VB Script commands to process command-line inputs. For example:
Dim args As Arguments
Dim value As String
value = Left(args(1), 5)
WScript.Echo "The first 5 characters of the first argument are " & value
Related Commands
WScript.Arguments
: Provides access to command-line arguments in a WSH environment.CommandLine
: An environment variable containing command-line arguments (not available in WScript).