日期:2014-05-16 浏览次数:20518 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript">
<!--
function run(){
var wsh = new ActiveXObject("WScript.Shell");
var batName = "a.bat";
// 获取当前文件的相对路径
//var pathName =window.location.pathname.replace("Test.jsp","");
//var batPath = pathName+batName;
var pathName = window.location;
alert("当前文件路径:"+pathName);
var fileName = pathName.toString().split("/")[pathName.toString().split("/").length-1];
alert("当前文件名:"+fileName);
var targetFile ="a.bat";
pathName = pathName.toString().replace(fileName,targetFile);
alert(pathName);
// 方式一:相对途径
var result = wsh.run(pathName);
// 方式二:绝对途径
//var result = wsh.run("c:/a.bat");
}
//-->
</script>
</head>
<body>
<input type="button" value="按钮" onclick="run()"/>
</body>
</html>
mspaint