CMD:睡觉的同时按任意键?

发布于 2024-08-14 18:08:17 字数 265 浏览 5 评论 0原文

我有这个批处理文件,它不断循环。我希望用户能够批量终止它,而不仅仅是单击 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风透绣罗衣 2024-08-21 18:08:17

删除暂停并将消息更改为“按 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?

月亮邮递员 2024-08-21 18:08:17

较新版本的 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文