It’s easy to ensure that scripts are run each time Windows logs on or off. You can schedule important procedures such as updates, backups, and can even run maintenance tasks on startup or shutdown. This is useful to speed up your computer and also to keep your windows system clean. The tool you need to use is the Group Policy editor of the Windows XP, Windows Vista and Windows 7.
In Windows XP, start the Group Policy editor by clicking ‘Start > Run’ and entering ‘gpedit.msc’. In Windows Vista and Windows 7 you can directly enter the command ‘gpedit.msc’ in the search bar of the start menu. For that however, you must have administrator rights to the computer.
To run a script when a user is logging on or of, Select ‘Local Computer Policy > User Configuration > Windows Settings > Scripts (logon / logoff)’ in the tree structure in the left pane of the Group Policy Editor.
In the right pane, you will see icons for ‘Logon’ and ‘Logoff’. If you wish to run your own script when a user is logging of, double-click ‘Logoff’, or double-click ‘Logon’ to run a script at startup.
The following steps are the same in both cases.
In the following dialog, click ‘Show Files’. Windows Explorer then shows a folder into which you can copy and paste the scripts to be run.
Scripts that are supposed to be run by the operating system when a user logs off are in the folder System32GroupPolicyUserScriptsLogoff and logs on in System32GroupPolicyUserScriptsLogon folder.
As soon as the scripts are in the respective folders, click ‘Add’. Then select the script file using ‘Browse’. In ‘Script parameter’, enter any parameters that are required. Confirm with ‘OK’. The selected script now appears in the list in the ‘Logoff properties’ or ‘Logon properties’ dialog box.
To run more than one script, add all other needed files to the list one after the other using ‘Add’. With ‘Edit’, you can change an already listed script or delete files from the list using ‘Remove’.
The sequence each one is executed in can be adjusted ‘Upwards’ or ‘Downwards’. Then click ‘OK’ and close the Group Policy Editor.
Windows now automatically runs the specified scripts while logging on or logging of. Contrary to the ‘Auto start’ folder that exists separately for every user account, the changes described here affect all users. Therefore, makes sure while programming the scripts that they are to be run for every user.