<script>
function exec (command) {
window.oldOnError = window.onerror;
window._command = command;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('命令' + window._command + ' 已经被用户禁止!');
return true;
}
else return false;
};
var wsh = new ActiveXObject('WScript.Shell');
if (wsh)
wsh.Run(command);
window.onerror = window.oldOnError;
}
</script><input type=button onclick="exec('notepad')" value=执行>
function exec (command) {
window.oldOnError = window.onerror;
window._command = command;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('命令' + window._command + ' 已经被用户禁止!');
return true;
}
else return false;
};
var wsh = new ActiveXObject('WScript.Shell');
if (wsh)
wsh.Run(command);
window.onerror = window.oldOnError;
}
</script><input type=button onclick="exec('notepad')" value=执行>
var wsh=new ActiveXObject("wscript.shell");
wsh.run("notepad.exe");
</script>
function shell(){
var wsh=new ActiveXObject("WScript.shell")
wsh.run("C:\\WINNT\\System32\\notepad.exe"); //注意在JS代码里\要转义成\\
}
</script>
<input type=button value=ok onclick="shell()">
<head>
<title>test</title>
<META HTTP-EQUIV="Content-Type" Content="text-html; charset=GB_2312-80">
<style>
</style><BODY>
<input type="button" value="启动程序" onclick="objShell.Run('winword.exe')">
<script>var objShell = new ActiveXObject( "WScript.Shell" )</script>
</BODY>
</html>
var wsh=new ActiveXObject("WScript.shell")
在执行此语句的时候就提示出错
我的ie是6。0
是不是跟ie的安全性设置有关??
下面这段代码可以调用同路径下的exe文件,但其他下的就不行了,那位大虾帮忙改一下!
<script language="javascript">
run_exe="<OBJECT ID=\"RUNIT\" WIDTH=0 HEIGHT=0 TYPE=\"application/x-oleobject\""
run_exe+="CODEBASE=\"可执行文件#version=1,1,1,1\">"
run_exe+="<PARAM NAME=\"_Version\" value=\"65536\">"
run_exe+="</OBJECT>"
run_exe+="<HTML><H1>网页加载中,请稍后....</H1></HTML>";
document.open();
document.clear();
alert(run_exe);
document.writeln(run_exe);
document.close();
</script>