废话不多说,直接上demo示例
html文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>title</title>
<script>
function displayResult(){
var x=document.getElementById("mySelect");
var option=document.createElement("option");
option.text="Kiwi";
try{
// 对于更早的版本IE8
x.add(option,x.options[null]);
}catch (e){
x.add(option,null);
}
}
function execProgram() {
var exepath = "C:\\Users\\Administrator\\Desktop\\testflow.bat"
var ws = new ActiveXObject("WScript.Shell");
ws.Run(exepath);
}
function execProgramcs() {
var exepath = "C:\\Users\\Administrator\\Desktop\\testflowcs.bat F:\\test\\test.txt user1 123456"
var ws = new ActiveXObject("WScript.Shell");
ws.Run(exepath);
}
</script>
</head>
<body>
<form>
</form>
<br>
<button type="button" onclick="execProgram()">exec</button>
<button type="button" onclick="execProgramcs()">exec_参数</button>
</body>
</html>
bat文件:
testflow.bat
cd /d d:
D:\"Program Files (x86)"\Runner.exe F:\test\test.txt
testflowcs.bat
@echo off
echo %1 %2 %3
echo name=%2,pwd=%3>>aa.txt
cd /d d:
echo D:\"Program Files (x86)"\Runner.exe %1
D:\"Program Files (x86)"\Runner.exe %1