Run Scripts Everytime You Logoff in Windows 7

If you want to perform some tasks or run scripts everytime you logoff in Windows 7, then it is very easy to do. This can be useful if you want to perform tasks like cleaning internet history, deleting some folders, copying some files each time you log off in Windows. This is also handy for creating regular backups of your important files. You can add scripts to run everytime at logoff using the Group Policy Editor in Windows 7. Here is how :

  1. First of all, create the a batch file (to be used as a script) and save it. You can add commands in this batch file to run other programs or perform some tasks. It is better to use automated programs which close down themselves after performing the intended tasks. For example, if you want to copy files from C:\Download to C:\PDF each time you log off, then the batch script would be as follows :
    Copy C:\Download*.* C:\PDF

    We save the script file as C:\Scripts\logoff.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 User Configuration → Windows Settings → Scripts (Logon/Logoff) as shown.

    Run Scripts at Logoff in Windows 7

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

    Run Scripts at Logoff in Windows 7

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

    Run Scripts at Logoff in Windows 7

  7. Click OK to close the Logoff Properties window.

That’s it. Now each time you logoff in Windows 7, the logoff script that you have added will run automatically before Windows logs you off. You can add as many scripts as you want – they will all run one after the another as you logoff.