-2
我正在尝试为客户端创建一个html页面,从中他将能够在任何远程桌面上启动或停止特定的窗口服务。总数的范围内的服务是20左右。而不是创建20(开始)+ 20(停止)+ 20(重新启动)批处理文件,我想有1个批处理文件与if if条件,我可以在JavaScript函数中传递参数。代码的html页面低于:从javascript函数传递参数到批处理文件
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
MyObject = new ActiveXObject("WScript.Shell")
function start()
{
MyObject.Run("\"E:\\start.bat\"");
}
function stop()
{
MyObject.Run("\"E:\\stop.bat\"");
}
function restart()
{
MyObject.Run("\"E:\\restart.bat\"");
}
</script>
<title>Our Company</title>
</head>
<body>
<table background-color:#f1f1c1; border="1" style="width:50%" align="center">
<tr>
<th style="text-align:center">Instance Name</th>
<th style="text-align:center">Accessible URL</th>
<th style="text-align:center">Status</th>
<th style="text-align:center">Start</th>
<th style="text-align:center">Stop</th>
<th style="text-align:center">Restart</th>
</tr>
<tr height="70%">
<td style="text-align:center">netadds</td>
<td style="text-align:center">
<a href="http://localhost/">localhost:netadds</a></td>
<td style="text-align:center">Running</td>
<td style="text-align:center"><button onclick="start()">Start</button></td>
<td style="text-align:center"><button onclick="stop()">Stop</button></td>
<td style="text-align:center"><button onclick="restart()">Restart</button> </td>
</tr>
</table>
</body>
</html>
和代码中的start.bat是:
@echo off
net start AMAPTestJetty8i0T1
if ERRORLEVEL 1 goto error
exit
:error
echo Could not start service
pause
请建议我怎么能适用,如果在批量else语句,并传递启动功能参数。
“重定向”可能是一个令人困惑的术语,因为您正在使用它;我会称之为“条件命令分隔符”... – aschipfl
对于你使用“条件命令分隔符”是什么?要重定向..... – SachaDee
“重定向”就像'echo text> file.log'; '&&'和'||'是完全不同的东西...... – aschipfl