I run exe from my asp.net with JavaScript using ActiveXObject. It runs successfully, except parameters:
我使用ActiveXObject从我的asp.net运行exe。运行成功,除参数:
function CallEXE() {
var oShell = new ActiveXObject("Shell.Application");
var prog = "C:\\Users\\admin\\Desktop\\myCustom.exe";
oShell.ShellExecute(prog,"customer name fullname","","open","1");
}
Example, I pass that like parameters,[1] customer name,[2] fullname, but after space character, Javascript perceive different parameter.
例如,我传递了参数,[1]客户名,[2]全称,但是在空格字符之后,Javascript感知到不同的参数。
How can I fix?
我怎样才能解决呢?
2 个解决方案
#1
1
ShellExecute
takes the 2nd parameter to be a string that represents all the arguments and processes these using normal shell processing rules: spaces and quotes, in particular.
ShellExecute将第二个参数作为一个字符串,该字符串表示所有的参数,并使用常规shell处理规则(特别是空格和引号)来处理这些参数。
oShell.ShellExecute(prog,"customer name fullname",...)
In this case the 3 parameters that are passed are customer
, name
, fullname
在这种情况下,传递的3个参数是customer、name、fullname
oShell.ShellExecute(prog,"customer 'a name with spaces' fullname",...)
oShell。ShellExecute(prog,“客户”名称与空格“fullname”,…)
As corrected/noted by Remy Lebeau - TeamB, double-quotes can be used to defined argument boundaries:
正如Remy Lebeau - TeamB所指出的,双引号可用于定义参数边界:
oShell.ShellExecute(prog,'customer "a name with spaces" fullname',...)
In this case the 3 parameters that are passed are customer
, a name with spaces
, fullname
在本例中,传递的三个参数是customer,一个带有空格的名称,fullname。
That is, think of how you would call myCustom.exe
from the command-prompt. It's the same thing when using ShellExecute
.
也就是说,想想如何称呼myCustom。exe命令提示符。使用ShellExecute也是一样的。
Happy coding.
快乐的编码。
#2
1
Try escaping your spaces with a backslash. The cmd.exe cd
command does this, maybe you'll get lucky and it'll work here as well...
试着用反斜线来逃离你的空间。cmd。exe cd命令可以做到这一点,也许您会很幸运,它也可以在这里工作……
oShell.ShellExecute(prog,"customer a\ name\ with\ spaces fullname", ...)
#1
1
ShellExecute
takes the 2nd parameter to be a string that represents all the arguments and processes these using normal shell processing rules: spaces and quotes, in particular.
ShellExecute将第二个参数作为一个字符串,该字符串表示所有的参数,并使用常规shell处理规则(特别是空格和引号)来处理这些参数。
oShell.ShellExecute(prog,"customer name fullname",...)
In this case the 3 parameters that are passed are customer
, name
, fullname
在这种情况下,传递的3个参数是customer、name、fullname
oShell.ShellExecute(prog,"customer 'a name with spaces' fullname",...)
oShell。ShellExecute(prog,“客户”名称与空格“fullname”,…)
As corrected/noted by Remy Lebeau - TeamB, double-quotes can be used to defined argument boundaries:
正如Remy Lebeau - TeamB所指出的,双引号可用于定义参数边界:
oShell.ShellExecute(prog,'customer "a name with spaces" fullname',...)
In this case the 3 parameters that are passed are customer
, a name with spaces
, fullname
在本例中,传递的三个参数是customer,一个带有空格的名称,fullname。
That is, think of how you would call myCustom.exe
from the command-prompt. It's the same thing when using ShellExecute
.
也就是说,想想如何称呼myCustom。exe命令提示符。使用ShellExecute也是一样的。
Happy coding.
快乐的编码。
#2
1
Try escaping your spaces with a backslash. The cmd.exe cd
command does this, maybe you'll get lucky and it'll work here as well...
试着用反斜线来逃离你的空间。cmd。exe cd命令可以做到这一点,也许您会很幸运,它也可以在这里工作……
oShell.ShellExecute(prog,"customer a\ name\ with\ spaces fullname", ...)