Asp.net ActiveXObject(“Shell.Application”)-如何用空格传递参数?
我使用ActiveXObject从asp.net和JavaScript运行exe。它成功运行,参数除外:Asp.net ActiveXObject(“Shell.Application”)-如何用空格传递参数?,asp.net,activex,shellexecute,Asp.net,Activex,Shellexecute,我使用ActiveXObject从asp.net和JavaScript运行exe。它成功运行,参数除外: function CallEXE() { var oShell = new ActiveXObject("Shell.Application"); var prog = "C:\\Users\\admin\\Desktop\\myCustom.exe"; oShell.ShellExecute(prog,"customer name fullna
function CallEXE() {
var oShell = new ActiveXObject("Shell.Application");
var prog = "C:\\Users\\admin\\Desktop\\myCustom.exe";
oShell.ShellExecute(prog,"customer name fullname","","open","1");
}
例如,我传递类似于参数,[1]客户名称,[2]全名,但在空格字符之后,Javascript感知不同的参数
如何修复?将第二个参数设置为一个字符串,该字符串表示所有参数,并使用常规shell处理规则处理这些参数和过程:特别是空格和引号
oShell.ShellExecute(prog,"customer name fullname",...)
在这种情况下,传递的3个参数是customer
,name
,fullname
oShell.ShellExecute(prog,“customer”是一个带有空格“fullname”的名称,…)
如Remy Lebeau-TeamB所更正/指出的,双引号可用于定义参数边界:
oShell.ShellExecute(prog,'customer "a name with spaces" fullname',...)
在这种情况下,传递的3个参数是customer
,带空格的名称
,全名
也就是说,考虑如何从命令提示符调用myCustom.exe
。使用ShellExecute
时也是如此
愉快的编码。试着用反斜杠转义空格。cmd.exe
cd
命令可以实现这一点,也许你会很幸运,它在这里也可以工作
oShell.ShellExecute(prog,"customer a\ name\ with\ spaces fullname", ...)
我希望您正在使用intranet应用程序…是的,我正在使用intranet Applicationsanks@pst,但它仍然是不同的参数:)@engcmreng Aww:(您最终得到了什么?使用双引号而不是单引号将参数值用空格括起来,例如:
oShell.ShellExecute(prog,“customer\”一个名称加空格\“fullname”,…)
或oShell.ShellExecute(prog,'customer'一个带有空格“fullname”的名称,…)
。