Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing a batch script on Windows shutdown

Is there any way, in Windows 7 Professional, to run a batch script (e.g., a .BAT file) when the user clicks on "shutdown" (not a batch file scheduled to shut down the machine, just one that runs only if the user clicks on "shutdown")?

Ideally, such a script would show the command prompt window and offer an option to cancel the shutdown procedure.

Solutions that do not require a third-party utility would be preferable.

like image 565
PNS Avatar asked Sep 15 '12 05:09

PNS


1 Answers

You can create a local computer policy on Windows. See the TechNet at http://technet.microsoft.com/en-us/magazine/dd630947

  1. Run gpedit.msc to open the Group Policy Editor,
  2. Navigate to Computer Configuration | Windows Settings | Scripts (Startup/Shutdown).

enter image description here

like image 111
bahrep Avatar answered Oct 16 '22 09:10

bahrep