用JS执行本地可执行文件
<script language="javascript" type="text/javascript">function runExe() { //创建ActiveX对象var shell = new ActiveXObject("WScript.shell"); //命令字符串,路径不能为反斜杠且路径中的文件夹名称中不得有空格, //如果出现空格,会被解析成两个命令var cmd="d:/test/target.exe";//true的t小写shell.run(cmd,1,true); } </script>? ? ? ?其中的shell.run参数介绍如下:
? ? ? ?参数1:执行命令字符串;
? ? ? ?参数2:应用执行时的窗口风格,1表示激活并显示窗口;
? ? ? ?参数3:是否等待命令执行完再向下执行,true表示等待。
?
?
?
参考资料:How to run an executable program on the client? Client-side scripts themselves cannot make system calls but on Windows systems you can insert Windows Script Host commands in client-side script.
Place this in the body of the HTML page. The button click will trigger off the function and the application is run.var shell = new ActiveXObject("WScript.shell");
Creates the WSH object as a new instance of an ActiveXObject.shell.run("notepad.exe", 1, true);
The run method of WSH starts the executable program.
The first parameter passed into the run method executes the command "notepad.exe".
The second parameter is optional and its integer value specifies the window style of the application launched. The 1 value will activate and display the window.
The third parameter is optional and its boolean value specifies if it is to wait for the command to complete before further execution. The true value will wait for the completion of the command.
Note that running such scripts properly require to change the client's security settings.