avirk
avirk

Reputation: 3086

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.

Upvotes: 3

Views: 36657

Answers (1)

Chirag Bhatia - chirag64
Chirag Bhatia - chirag64

Reputation: 4516

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
)

Upvotes: 5

Related Questions