从另一个传递参数的vbscript文件调用vbscript

use*_*210 2 vbscript

我使用下面的脚本来调用另一个脚本.问题是我必须将我通过WScript.Arguments检索的参数传递给我正在调用的第二个脚本.有人请告诉我该怎么做.

Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")

objShell.Run "TestScript.vbs"    

Set objShell = Nothing
Run Code Online (Sandbox Code Playgroud)

Ans*_*ers 5

You need to build your argument list with proper quoting of the arguments. You also need to differentiate between named and unnamed arguments. At the very minimum, all arguments with spaces in them must be put between double quotes. It doesn't hurt, though, to simply quote all arguments, so you could do something like this:

Function qq(str)
  qq = Chr(34) & str & Chr(34)
End Function

arglist = ""
With WScript.Arguments
  For Each arg In .Named
    arglist = arglist & " /" & arg & ":" & qq(.Named(arg))
  Next
  For Each arg In .Unnamed
    arglist = arglist & " " & qq(arg)
  Next
End With

CreateObject("WScript.Shell").Run "TestScript.vbs " & Trim(arglist), 0, True
Run Code Online (Sandbox Code Playgroud)