如何使用JavaScript运行exe或bat文件

时间:2016-07-15 23:24:23

标签: javascript batch-file

我希望有人可以提供帮助。我试图通过点击按钮来运行文件,但这两种方法都不能与IE或Firefox一起使用。

<html>
<head>
</head>

<body>

<script language="JavaScript" type="text/javascript">

function myFunction1(){
batch = "C:\\personallaner\\istbat.bat"; 
obj=new ActiveXObject('WScript.Shell');
   obj.Run (batch); 
}

function myFunction2(){
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "C:\\personallaner\\istbat.bat"; 
oShell.ShellExecute(commandtoRun,"","","open","1");
};

</script>

<input id="button" type="submit" name="button" onclick="myFunction1()" value="a"/>
<input id="button" type="submit" name="button" onclick="myFunction2();" value="b"/>

</body>
</html>

0 个答案:

没有答案