試試這個 - 只接受一個參數 - 秒到countdown.Should與.bat
擴展名保存:
<!-- :
:: countdown.bat
@echo off
if "%~1" equ "" (
echo seconds not passed
exit /b 1
)
echo %*|mshta.exe "%~f0"|more
exit /b %errorlevel%
-->
<html>
<head><title>It's the final countdown</title></head>
<body>
<p>Seconds left</p>
<div id="countdown">--</div>
<button onclick='quit()'>QUIT</button>
<script language='javascript' type="text/javascript">
function parse() {
var seconds=0;
try {
var fso2= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(0);
argline=fso2.ReadLine();
var args=argline.split(" ");
var seconds=parseInt(args[0]);
//var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1);
//fso.Write("wait for: " + milliseconds);
} catch (err) {
errmessage = "cannot get the milliseconds";
var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1);
fso.Write(errmessage);
close();
}
seconds = document.getElementById('countdown').innerHTML=seconds;
countdown();
}
var seconds;
var temp;
function countdown() {
seconds = document.getElementById('countdown').innerHTML;
seconds = parseInt(seconds, 10);
if (seconds == 1) {
temp = document.getElementById('countdown');
close();
//return;
}
seconds--;
temp = document.getElementById('countdown');
temp.innerHTML = seconds;
timeoutMyOswego = setTimeout(countdown, 1000);
}
//countdown();
window.resizeTo(400,250)
parse();
function quit() {
close();
}
//itsTheFinalCountdown(10000);
</script>
</body>
</html>
[見這個答案](http://stackoverflow.com/ a/28323363/1683264)的想法。沒有用於從批處理腳本創建警報窗口的本機命令,但是您可以藉助Windows腳本宿主(VBScript或JScript)進行彈出。 – rojo 2015-02-11 04:51:59