您的位置:首页 > Web前端 > JavaScript

用js调用exe程序

2010-03-08 17:36 323 查看
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<script>

/**

浏览器里有下载警告框和安全警告框出现

*/
function ExeRun(command)
{
window.oldOnError=window.onerror;
window._command=command;
window.onerror=function(err)
{
if(err.indexOf('automation')!=-1)
{
alert("命令"+window._command+"已经被用户禁止!");
return true;
}
else return false;
}
var wsh=new ActiveXObject("WScript.Shell");
if(wsh)
wsh.Run(command);
window.onerror=window.oldOnError;
}

/**

浏览器里没有下载警告框和安全警告框出现

*/

function run(command){
var wsh=new ActiveXObject("WScript.Shell");
alert(wsh);
if(wsh){
wsh.exec(command);
}
}
</script>
<input type=button onclick="ExeRun('Explorer file:///C://Documents and Settings//feng.wen//桌面//kostal')" value="打开文件夹">
<input type=button onclick="ExeRun('Explorer C://Program Files//TTPlayer//TTPlayer.exe')" value="千千静听">
<input type=button onclick="ExeRun('Explorer /e,/root,//DigitalTitan')">
<input type=button onclick="ExeRun('Explorer /select,C://WinNT//')">
<input type=button onclick="ExeRun('Explorer C://Documents and Settings//feng.wen//桌面//快捷方式//birt2.2正式版.exe')" value="运行快捷方式">
<input type=button onclick="run('C:/Program Files/TTPlayer/TTPlayer.exe')" value="千千静听">
<input type=button onclick="run('notepad.exe')" value="记事本">
<input type=button onclick="run('mstsc.exe')" value="远程桌面">
<input type=button onclick="run('C://Program Files//Maxthon2//Maxthon.exe')" value="遨游">
</BODY>
</HTML>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: