CMD:睡觉的同时按任意键?
我有这个批处理文件,它不断循环。我希望用户能够批量终止它,而不仅仅是单击 X。
这就是我所需要的(以某种方式):
@echo off
:proc
cls
rem All kind of stuff...
echo Hit any key to terminate...
sleep 1
@pause>nul
但是,当然,睡眠和暂停不能同时工作。
怎么可能?
i have this batch file, which makes constantly a loop. I want the user to be able to terminate it in the batch, not just clicking the X.
This is what i need (somehow):
@echo off
:proc
cls
rem All kind of stuff...
echo Hit any key to terminate...
sleep 1
@pause>nul
But, of course, sleep and pause can't work at the same time.
How is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
删除暂停并将消息更改为“按 Ctrl + C 终止”。据推测该脚本有一个您没有显示的“goto :proc”?
Remove the pause and change the message to "Hit Ctrl + C to terminate". Presumably the script has a "goto :proc" that you are not showing?
较新版本的 Windows 具有 TIMEOUT 命令来执行此操作。
http://technet.microsoft.com/en -us/library/cc754891%28v=ws.10%29.aspx
More recent editions of Windows has the TIMEOUT command that does just this.
http://technet.microsoft.com/en-us/library/cc754891%28v=ws.10%29.aspx