Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
November 21, 2006
You can extract named and unnamed arguments from the command line. If you have a /Name1: named argument, the following code can extract it, along with the first unnamed argument, if any:
WScript.Echo "There are a total of " & WScript.Arguments.Count & " arguments."WScript.Echo "There are " & WScript.Arguments.Named.Count & " named arguments."WScript.Echo "There are " & WScript.Arguments.Unnamed.Count & " unnamed arguments."If WScript.Arguments.Named.Count > 0 Then if WScript.Arguments.Named("Name1") "" Then WScript.Echo "/Name1:" & WScript.Arguments.Named("Name1") Else WScript.Echo "No or nul ""/Name1:"" named argument was passed." End IfEnd IfIf WScript.Arguments.Unnamed.Count > 0 Then WScript.Echo "First unnamed argument:" & WScript.Arguments.Unnamed(0)End If
You May Also Like