简体   繁体   中英

A batch file for shutdown with prompt option to abort it and re-run after a certain time of amount?

I have a batch file to shutdown the PC

@echo off
Shutdown /s /f /t 600 /c "Your system will shutdown in 10 min"

To abort this operation I've another one

shutdown /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.

I've Googled for it but got nothing so far. Only got some 3rd party tools to do shutdown without abort option.

Is it possible? If yes any help would be appreciated.

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

@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
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM