【问题标题】:How to pass two arguments to cmd via wscript.shell如何通过 wscript.shell 将两个参数传递给 cmd
【发布时间】: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


    【解决方案1】:

    CMD 的运行频率高于网页中显示的结果。它使用以下代码运行:

    runcmd = """path\to\run.cmd"" " & arg1 & " " & arg2 & ""
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-05
      • 2018-09-29
      • 1970-01-01
      • 2019-10-27
      • 1970-01-01
      • 2013-08-19
      • 2023-03-11
      相关资源
      最近更新 更多