1

I want to run a script that reboots the computer when the shutdown button is clicked on Windows 10 . I have tried this solution https://stackoverflow.com/questions/12434863/executing-a-batch-script-on-windows-

this is the batch script I am using

shutdown -r -f -t 0

However this doesn't work . Is there a way achieve this ,if so please let me know

1 Answers1

1

Go into windows task scheduler.

  1. Create a basic task.
  2. Enter a Name and Description, click next
  3. You should now be in the trigger option. Set the trigger as "When a specific event is logged" and click next.
  4. In the Log drop down, choose "system"
  5. In the Source dropdown, select "Kernal-power"
  6. and in the Event ID, put in "109"

After that, click next for start a program and then load your script in. This should run the script before the shutdown command has been executed. I could be wrong, but these steps should point you in the right direction.

I'm also sure that a quick regedit would be able disable the shutdown button.

edit

Here is that regedit fix that might meet your needs. http://www.intowindows.com/how-to-remove-shutdown-restart-hibernate-options-from-start-menu-shutdown-dialog-box/

BigElittles
  • 320
  • 2
  • 11
  • I know this may be a stupid question but once i create the event and try to shutdown the task will be triggered right , Also are you sure that the shutdown event ID is 109??Thanks – Sarthak Bansal Jul 06 '16 at 13:53
  • Everything I've found online indicates that it is 109. If you'd like to confirm that on your PC go into the event viewer and search for 109 and see what the event is. – BigElittles Jul 06 '16 at 14:44
  • I tried doing the above however when I shutdown the computer the script doesn't run . Is there a particular folder in the task scheduler where I need to add this task ? – Sarthak Bansal Jul 07 '16 at 14:42