Changing the location of Windows Special Folders on the command line

23 December 2011

The special folders in Windows 7 such as 'My Music, My Documents, My Pictures or my Videos' be default point to Folders under the users home directory such as C:\users\username\Documents or C:\users\username\Music.

I have all my music, videos and photos on separate drives but like to point the special folders to these locations.

In the GUI this is pretty straight forward, right click on the special folder in question and then on the 'Location' tab. Just change the path to the new desired path and OK the dialog.


However there are quite a few of these special folder I like to change, plus I have to change them for several users on several computers and this every time I reinstall an OS.

The location of the special folders is defined in the registry under the following key:


There, we have a sub keys: "User Shell Folders" and "Shell Folders", we need to change the information in both places. Here is an example of a batch file to change the locations for Favorites and Videos:

reg.exe ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /f /v Favorites /t REG_EXPAND_SZ /d "F:\Users\Joe\Favorites"
reg.exe ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /f /v Favorites /t REG_SZ /d "F:\Users\Joe\Favorites"

reg.exe ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /f /v "My Video" /t REG_EXPAND_SZ /d "M:\Media\Videos"
reg.exe ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /f /v "My Video" /t REG_SZ /d "M:\Media\Videos"

After you run this batch file under the user account for which you want to make the changes, log off that user and back on again and the changes should be in affect.

Pages in this section


ASP.Net | Community | Development | IIS | IT Pro | Security | SQL (Server) | Tools | Web | Work on the road | Windows