How can I pass and access command line arguments in VBscript?
option. You can test command line arguments by running an executable from the "Command Prompt" in Windows or from the "DOS prompt" in older versions of Windows. You can also use command line arguments in program shortcuts, or when running an application by using Start -> Run.
I googled it & got to know that we can run VBScript from command line by executing below command: For Example my vbscript name is Converter. vbs & it's present in folder D:\VBS .
Set args = Wscript.Arguments For Each arg In args Wscript.Echo arg Next
From a command prompt, run the script like this:
CSCRIPT MyScript.vbs 1 2 A B "Arg with spaces"
Will give results like this:
1 2 A B Arg with spaces
If you need direct access:
WScript.Arguments.Item(0) WScript.Arguments.Item(1) ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With