使用倒计时和应用程序启动批处理脚本创建消息框

时间:2014-03-10 15:52:29

标签: windows batch-file messagebox

需要延迟启动应用程序。我需要编写一个批处理文件,显示一条弹出消息,显示" POS将加载%xx%SECONDS。请等待......"

我希望%xx%可以倒计时,但如果它仍然是静态的,那没关系。一旦20秒过去,我需要批处理脚本来调用我需要的应用程序,然后关闭。

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:0)

一种方式:

@echo off
@echo WScript.CreateObject("WScript.Shell").Popup "I will dissapear in 5 seconds", 5 > %TEMP%\wait.vbs 
wscript %TEMP%\wait.vbs
echo done

而不是.vbs制作.hta

@echo off
%temp%\wait.hta
echo done

制作档案

<html>
<head>
<title>Wait</title>
<HTA:APPLICATION APPLICATIONNAME="PleaseWait" ID="PleaseWait" VERSION="1.00" SYSMENU="no" MAXIMIZEBUTTON="no" MINIMIZEBUTTON="no" SCROLL="no" />
</head>
<script language="VBScript">
Sub Window_OnLoad
    window.resizeTo 300, 100
    window.moveTo (window.screen.width - 300) / 2, (window.screen.height - 100) / 2
End Sub
</script>
<script language="Javascript">
var count = 5, counter = setInterval(timer, 1000);
function timer() {
    if ((count -= 1) <= 0) {
        clearInterval(counter);
        window.close();
    } 
    document.getElementById("secs").innerHTML = count;
}
</script>
<body>
<h2>Wait <span id="secs"></span></h2>
</body>
</html>

答案 1 :(得分:0)

这是我修改过的2007年发布的例程:

@echo off 
cls & echo.
set "text=....Waiting for 20 seconds...."
call :animate
set "text=....Waiting for 10 seconds...."
call :animate
set "text=Running application..."
call :animate

Rem Startup routine goes here
pause
goto :EOF


:animate
:: calculate the length of the text string
for /f "tokens=1* delims=:" %%a in (
'^(for %%i in ^("%text%" .^) do @echo %%i^) ^| findstr /o .^| ^
findstr /v /b 0') do set /a v=%%~a-5

for /L %%a in (1,1,%v%) do call set "txt=%%text:~0,%%a%%"&call :show out
echo %text%
ping -n 2 127.0.0.1 >nul
cls & echo.
for /L %%a in (2,1,%v%) do call set "txt=%%text:~%%a%%"&call :show in
goto :EOF

:show
for %%a in (/ - \ ^| / - \ ^|) do (
if %1==out echo %txt%^%%a
if %1==in  echo ^%%a%txt%
for /L %%b in (1,1,1000) do set dummy=%%b
cls & echo.
)
goto :EOF