windows 用于关闭的批处理文件,带有提示选项以中止它并在一定时间后重新运行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11149995/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
A batch file for shutdown with prompt option to abort it and re-run after a certain time of amount?
提问by avirk
I have a batch file to shutdown the PC
我有一个批处理文件来关闭 PC
@echo off
Shutdown /s /f /t 600 /c "Your system will shutdown in 10 min"
@echo off
Shutdown /s /f /t 600 /c “您的系统将在 10 分钟后关闭”
To abort this operation I've another one
要中止此操作,我还有另一个操作
shutdown /a
关机 /a
Now what I'm looking for is there any way that when I launch the first batch file it should prompt me to abort the operation or not. If I abort the operation it should be prompt me after 10 min the same option and I want it in loop until I don't accept the operation to done.
现在我正在寻找有什么方法可以在我启动第一个批处理文件时提示我是否中止操作。如果我中止操作,它应该在 10 分钟后提示我相同的选项,我希望它在循环中,直到我不接受操作完成。
I've Googled for it but got nothing so far. Only got some 3rd party tools to do shutdown without abort option.
我已经用谷歌搜索过,但到目前为止一无所获。只有一些 3rd 方工具可以在没有中止选项的情况下进行关机。
Is it possible? If yes any help would be appreciated.
是否可以?如果是,任何帮助将不胜感激。
回答by Chirag Bhatia - chirag64
Did this in a single batch file. If you want it to run every 10 minutes don't want the window to stay there for those 10 minutes timegap, then remove the 'timeout and goto' and run it using the Windows Task Scheduler
在单个批处理文件中执行此操作。如果您希望它每 10 分钟运行一次,不希望窗口在 10 分钟的时间间隔内停留在那里,则删除“超时并转到”并使用 Windows 任务计划程序运行它
@ECHO OFF
:myLabel
SHUTDOWN /S /F /T 600
SET /P continue="Your computer is about to shutdown in 10 min do you want to abort (y/n): "
IF %continue% EQU y (
SHUTDOWN /A
TIMEOUT /T 600 /NOBREAK
GOTO myLabel
)