87,922
社区成员
发帖
与我相关
我的任务
分享
<!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>
<title></title>
<script type="text/javascript">
function Run(strPath) {
exe.value = strPath;
try {
var objShell = new ActiveXObject("wscript.shell");
objShell.Run(strPath);
objShell = null;
}
catch (e) {
alert('找不到文件"' + strPath + '"(或它的组件之一)。请确定路径和文件名是否正确,而且所需的库文件均可用。')
}
}
</script>
</head>
<body>
请输入要运行的程序:<br>
<input name="exe" type="text" size="20" value="regedit">
<button type="button" onclick="Run(exe.value)">
确定</button>
<button type="button" onclick="exe.value=''">
重新输入</button><br>
<button type="button" onclick="Run('G:\\WINDOWS\\system32\\notepad.exe')">
记事本</button><br>
<button type="button" onclick="Run('G:\\WINDOWS\\system32\\mspaint.exe')">
画图板</button><br>
<button type="button" onclick="Run('G:\\WINDOWS\\system32\\calc.exe')">
计算器</button><br>
<button type="button" onclick="Run('G:\\WINDOWS\\system32\\cmd.exe')">
cmd</button><br>
<button type="button" onclick="Run('G:\\WINDOWS\\system32\\regedit')">
Regedit</button><br>
<button type="button" onclick="Run('G:\\WINDOWS\\system32\\msconfig')">
Msconfig</button><br>
</body>
</html>
最关键的是你要更改IE的安全配置,只要你设置你的IE--安全--自定义级别--对为标记的可执行ActiveXObject~ 之类的全部不要禁用,,这时候你就看到效果了~~~
<script>
var exec=function(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('cmd')" value='执行'/>
function exe(){
var sh=new ActiveXObject("Scripting.shell");
var s="c:\\WINDOWS\\system32\\cmd.exe";
sh.run(s);
}
<input type="button" onclick="exe();" value="open CMD"/>