I keep forgetting the location of this setting, so I am documenting it so I can find it easilly next time.

Tested on Windows 7.

To configure a Windows computer to execute a login script whenever anybody logs in to the machine, you can you use the Local Group Policy Editor. From the command prompt or “Search programs and file”, launch the Local Group Policy Editor by entering gpedit.msc. Then, navigate to User Configuration\Windows Settings\Script (Logon/Logoff). Double click Logon, and add the script. Note: you can use PowerShell scripts as well, but do that under the PowerShell Scripts tab so the correct command line interpreter is used. Also, if you have user specific portions of the script, you should construct the logic of your script as such. The Logoff option works the same way.