I have been trying to create a batch file(s) that triggers my Windows 8 PC to begin shutting down after 30 seconds has elapsed and that also has a warning message: "Your PC will shutdown in 30 seconds! Please press Cancel button to abort Shutdown." I have created the following batch files on my desktop:
shutdown /s /c "Your PC will shutdown in 30 seconds! /t 30
and:
shutdown /a
and it does shutdown the pc, but the message will not show until exactly 30 seconds later and goes away within 1 second and starts shutting down with no way to stop it. I have even tried to do the shutdown /a batch file before the 30 seconds is up with no luck in stopping the shutdown.
Is the commands not correct for Windows 8?
I would like to have one script with the popup message warning and with a cancel (abort) button prior to the 30 seconds expiring or at least get the 2 batch files to work in Windows 8 with a warning message and the abort batch file both working.
Not sure if Windows 8 has a command or something that works but would like to get it working. Any help is so greatly appreciated!!!
Thanks you very much!
Billy
Try
@echo off
echo Your PC will shutdown in 30 seconds! Press CTRL+C to abort.
ping -n 31 127.0.0.1>nul
shutdown /s
The PING command is a secure way of pausing the batch script for desired amount of time. More info here: How to wait in a batch script?
Pressing Ctrl-C will abort a batch script from continuing.