且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用参数调用 VBScript

更新时间:2023-08-31 17:43:52

你需要用

Set objShell = CreateObject("WScript.Shell")

在你可以使用它的 .Run 方法之前.

before you can use its .Run method.

此外,VBScript 不会扩展字符串内的变量,因此您需要将参数连接到命令字符串的其余部分:

Also, VBScript doesn't expand variables inside strings, so you'll need to concatenate your argument to the rest of the command string:

objShell.Run "ArgumentTest2.vbs " & arg1

请注意,如果标记包含空格,您需要将它们放在双引号中:

Note that you'll need to put tokens in double quotes if they contain spaces:

arg1 = "My Argument"
objShell.Run "ArgumentTest2.vbs """ & arg1 & """"