Can I run a script to give a user an optioon to reboot or postpone after an automatic reboot task?

0

I have a task to reboot a pc at a specific time every night. Is there a way to create a popup that will give the user an option to Restart Now or Postpone (with a time frame) on Windows 7?

Ellen

Posted 2014-11-20T21:51:19.120

Reputation: 1

Answers

1

You can do this with Choice.

Assuming that your script is a batch file, you can do the following:

choice /C rp /D r /T 60 /M "Your system needs to be rebooted. Press [r] to Reboot, or [p] to Postpone. If you do not make a choice for 60 seconds, the system will reboot.

if "%ERRORLEVEL%"=="2" goto postpone
if "%ERRORLEVEL%"=="1" goto reboot

:reboot
shutdown -r -f -t 0

:postpone

LPChip

Posted 2014-11-20T21:51:19.120

Reputation: 42 190

Thank you. We are planning on scheduling this as a daily task on the PC running Windows 7. We would optimaly like to have the batch file reschedule the task as a one time task for 2 hours in the future if the user selects postpone. Then the one time task should be deleted after it runs. Is that possible? – Ellen – 2014-11-21T19:40:41.217

Its not easily achievable. Taskschedular has commandline switches to modify or create tasks, but its pretty advanced stuff. – LPChip – 2014-11-21T22:53:26.613

0

If you have written a script to showdown exe with /t time limit it show a popup that windows will be shut down in 1 mins for below command.

shutdown /s /t 60

If the user wanted to cancel the shutdown counting he can run the below command in cmd and abort shutdown. (or) you can write a batch file for the user so that he can run that file once he get the popup

shutdown /a

vembutech

Posted 2014-11-20T21:51:19.120

Reputation: 5 693