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

js调用exe可执行文件(IE8)

2017-12-12 09:25 288 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title> IE或Firefox执行Exe文件 </title>
<script>
function longzhoufeng() {
var exepath = "C:\\WINDOWS\\NOTEPAD.EXE";
if(!document.all) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file = window.Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(exepath);
var run = window.Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
run.init(file);
var parameters = [""];
run.run(false, parameters, parameters.length);
}
else {
var ws = new ActiveXObject("WScript.Shell");
ws.Exec(exepath);
}
}
</script>
</head>
<body>
<input type="button" onclick="javascript:longzhoufeng()" value="执行EXE"/>
</body>
4000

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: