[批处理]倒计时5秒后运行程序,5秒之类按任意键退出

来源:互联网 发布:php和office 知乎 编辑:程序博客网 时间:2024/05/16 07:35

抄袭自http://www.bathome.net/viewthread.php?tid=4075&highlight=%B5%B9%BC%C6%CA%B1

 

@echo off
set tt=5
if not "%1"=="" goto %1
del /f "%temp%/#" 2>nul
start /b "" "%~f0" :count
pause
>"%temp%/#" type nul
exit
:count
if %tt%==0 (
title 自动运行...
for /f "tokens=2" %%a in ('tasklist /fi "windowtitle eq 自动运行..." /nh') do (taskkill /f /pid %%a>nul)

cls
color 1E
title 正在运行...
@echo 请用文本编辑器打开本文件
@echo 去掉下面一行的rem,在后面输入想运行的命令。
rem start 要运行程序的绝对路径
pause

exit
)
if exist "%temp%/#" (
del "%temp%/#"
exit
)
cls&echo 按任意键退出
echo %tt%秒后自动运行
ping -n 2 127.1>nul
set /a tt-=1
goto :count