Run Scripts At Shutdown in Windows 7

Some of us want to make a regular backup of some important files (or run some other tasks) automatically every time when we shutdown the computer. You can do so easily in Windows 7 by utilizing the shutdown script feature. Here is how :

  1. First of all, create the command script (or a batch file) and save it. You should write the script as a batch file though the PowerScript is also supported. For example, if you want to make a backup of all the files in C:\Project to a network drive X:, then the script would be as follows :
    Copy C:\Project\*.* X:\

    We save the script file as C:\MakeBackup.bat.

  2. Press the key combination Windows logo key + R to open the Run dialog.
  3. In the Run Dialog, type gpedit.msc and press Enter to open the Group Policy Editor.

    Run Dialog in Windows 7

  4. In the Group Policy Editor, open Computer Configuration → Windows Settings → Scripts (Startup/Shutdown) as shown.

    Group Policy Editor in Windows 7

  5. Double-click on Shutdown in the right side pane. In the window that opens up, click on the Add button.

    Shutdown Script Properties window

  6. Browse to your script file and put in any parameter (only if it accepts parameters). Then click OK button.

    Adding a shutdown script

  7. Click OK to close the Shutdown Properties window.

That’s it. Now each time you shutdown the computer, the shutdown script that you have added will run automatically before the computer shuts down. You can add more than one script if you want.

Note : If you are not able to run scripts at shutdown, then there is a workaround. Try adding scripts to run at log off. When you shutdown, the Windows first logs you off and so log off scripts also run every time you shutdown your computer. To add scripts for log off, read Run Scripts Everytime You Logoff in Windows 7.