在 VBscript 中使用命令行参数

如何在 VBscript 中传递和访问命令行参数?

151455 次浏览
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)
...