When a user of mine clicks the 'Restart' button on their system (Windows 10 in an Active Directory environment) I would like a quick batch script to run BEFORE the restart takes place.

My thought is that if I could remap the restart button to run the batch script and then have the last line in that batch script run the restart command.

How can I make this happen... unfortunately almost all searches including the word "remap" are talking about remapping keyboard keys.

EDIT: I am aware that we can run a shutdown script... unfortunately, I only want to run this script on RESTART, not on shutdown. If there was a way to differentiate, that would effectively solve the problem as well.

  • See this post: superuser.com/questions/773651/… Mar 28, 2018 at 18:19
  • 1
    This feels like an XY problem. Why exactly do you feel like you need to do this?
    – EBGreen
    Mar 28, 2018 at 18:50
  • 1
    The solution to this problem is to disable the ability for the user to restart the machine by using a group policy and write a script that exists on the desktop, that the user uses instead. If this isn't acceptable then you will have to use a scheduled task, when the user is logging off, and run your script instead.
    – Ramhound
    Mar 28, 2018 at 18:55
  • EBGreen - because we have something that needs to happen on startup before any startup scripts could run. (effectively, we need 'restart' to alter the boot process and the only way to do that is to restart in a certain way)
    – lowcrawler
    Mar 29, 2018 at 15:06
  • @lowcrawler: what if the user shut down and then starts, don't you need to run it? Mar 29, 2018 at 16:36

1 Answer 1


On our Windows domains, we configure a GPO in the following location:

User Configuration\Administrative Templates\Start Menu and Taskbar

Within that hiearchry, we enable the following policy:

Remove and prevent access to the Shut Down, Restart, Sleep, and Hibernate commands  

Once configured, the Windows 10 Start menu button will only have the option to Sign out.

After that, you can copy your custom batch file to the Public desktop (%SystemDrive%\Users\Public\Desktop) to make it readily available to all users, ensuring that you have the restart command (shutdown /r /f /t 0) at the end of the sequence.

  • I'm going to mark this as the answer, as it appears to be the only solution. However, it doesn't really solve the original problem.
    – lowcrawler
    Apr 16, 2018 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.