从Javascrip 脚本中执行.exe 文件

You need to escape the backslashes, e.g.,

var commandtoRun ="C:\\Documents and Settings\\User\Desktop\\ABCD.exe";

Update:

This works fine on my machine:

var oShell =newActiveXObject("Shell.Application");var commandtoRun ="C:\\Windows\\notepad.exe"; 
oShell.ShellExecute(commandtoRun,"","","open","1");

Update 2

You can save this as a file with the extension .hta and it should work in your browser:

<HTA:APPLICATIONID="oMyApp"APPLICATIONNAME="Application Executer"BORDER="no"CAPTION="no"SHOWINTASKBAR="yes"SINGLEINSTANCE="yes"SYSMENU="yes"SCROLL="no"WINDOWSTATE="normal"><scripttype="text/javascript"language="javascript">var oShell =newActiveXObject("Shell.Application");var commandtoRun ="C:\\Windows\\notepad.exe"; 
oShell.ShellExecute(commandtoRun,"","","open","1");</script>

From:
Running .exe from Javascript

How to launch an EXE from Web page (asp.net)

posted @ 2014-03-27 17:00  happyu0223  阅读(213)  评论(0编辑  收藏  举报