【发布时间】:2019-08-22 17:11:38
【问题描述】:
我们使用在链接中有两个变量的 aspx 网页。示例:
aspxpage.aspx?argument1=arg1&argument2=arg2
aspx 调用 .cmd 并需要将两个参数传递给它,除以空格。当我开始研究这个时,没有通过任何参数。代码是:
dim wshell
dim arg1
dim arg2
dim runcmd
arg1 = Request.Querystring("arg1")
arg2 = Request.Querystring("arg2")
wshell = CreateObject("WScript.Shell")
runcmd = """path\to\run.cmd """ + arg1 + " " + arg2
wshell.run (runcmd, 1, true )
wshell = nothing
结果什么都没有,因为没有参数传递给 .cmd 并且没有发生错误。
将 runcmd 行更改为:
runcmd = """path\to\run.cmd"" " & arg1 & " """ & arg2 & """"
结果显示只有 arg1 被传递。不会出现错误消息。
如何确定也传递了 arg2。
找到了类似的问题,但使用该代码没有结果,并给出了结尾“丢失等”的错误。
Passing parameters from vbscript to batch file first answer第二行代码与我的代码设置相同,但不起作用。
【问题讨论】:
标签: asp.net cmd parameters parameter-passing wscript.shell