Customise default "shutdown/restart" behaviour in Windows 10 to run prior commands

istane

Prominent
Nov 26, 2017
4
0
510
0
I have created two custom .bat files that shutdown/restart the computer, and which beforehand run some other (simple) commands that I want run just before shutting down.

Now I shut down/reboot my computer by doubleclicking these bat files. Not a big deal, but I was wondering whether one could modify the default behaviour of the power buttons in the start menu to do that (by having them running the .bat files, or maybe in some other way having them run the same commands before the do what they do).
 

gardenman

Reputable
Herald
Jun 16, 2016
1,560
3
4,715
411
Hi. You could probably run the batch files with the Task Scheduler, but from what I have read, by doing this the batch files need to be really quick or Windows will shut down before they finish. Here are a couple of pages explaining the process:
https://superuser.com/questions/165142/using-task-scheduler-to-run-a-task-before-shutdown
https://stackoverflow.com/questions/101647/how-to-schedule-a-task-to-run-when-shutting-down-windows

If you really must run a longer script, then consider getting the Classic Shell start menu. I've been using it for years and I just tested out using a custom shutdown command and it worked. Here is basically what I did:

Note: Classic Shell is no longer in development. It's likely that parts of it will begin to stop working with additional Windows updates. The author did release the source code so maybe someone will pick it up and continue development of it.

Additional ideas from others are welcome.
 

istane

Prominent
Nov 26, 2017
4
0
510
0


Thanks for the thorough answer! The links contain all the information I needed. I used the task scheduler and it seems to work fine (I think). I have a very short script so there does not seem to be any issue.
 

Similar threads