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 If End If If WScript.Arguments.Unnamed.Count > 0 Then WScript.Echo "First unnamed argument:" & WScript.Arguments.Unnamed(0) End If
0 comments
Hide comments