function exec() {window.onerror = function (err) {if (err.indexOf('utomation') != -1) {alert('命令已被用禁止!');return true;} else{return false;}};var wsh = new ActiveXObject('WScript.Shell');if (wsh){wsh.run("C:/Users/Vision/Desktop/1111.sql");/**varbatName="a.bat";//获取当前文件的相对路径//varpathName=window.location.pathname.replace("Test.jsp","");//varbatPath=pathName+batName;varpathName=window.location;alert("当前文件路径:"+pathName);varfileName=pathName.toString().split("/")[pathName.toString().split("/").length-1];alert("当前文件名:"+fileName);vartargetFile="a.bat";pathName=pathName.toString().replace(fileName,targetFile);alert(pathName);//方式一:相对途径varresult=wsh.run(pathName);//方式二:绝对途径//varresult=wsh.run("c:/a.bat");**/}window.onerror = window.oldOnError;}
如果觉得《JavaScript执行bat文件清理浏览器缓存》对你有帮助,请点赞、收藏,并留下你的观点哦!