Environment Variables for Windows' Built-in Libraries?

All we need is an easy explanation of the problem, so here it is.

Does Windows 7 define environment variables for pre-existing Libraries? I am curious because I often use these when typing a path in Open/Save dialogs or from the Run prompt. For example, to get to the current user’s Firefox settings directory, run:


It’s a handy shortcut, and I was hoping to find something similar for library paths. For example:


I understand that libraries aggregate one-or-more top-level folders, so there could be ambiguity. Microsoft has a list of environment variables, but most are not accessible via the Windows UI. This question also links to a nice list, but does not include a user’s Documents folder, Music folder, etc.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Windows Libraries are in fact just xml files which define how to display a collection of folders. They are displayed using a special shell extension which is built in to Windows. Since they are not real folders, files and sub-folders cannot be accessed directly via a path.

With an open explorer window, you can type in the address bar:


This does not seem to work from the File Name box of open/save dialogs. Nor does it work with the run command.

What you can do about it:

Windows Vista introduced the “Known Folders” concept. It replaces the older “constant special item ID list” (CSIDL) methodology used in XP. There is an excellent post on the Windows Blog; it discusses this change and provides an overview of the *.library-ms file structure.

Known Folders have GUIDs. To access them via command line, prefix your URI with knownfolder:. There are dozens defined. To access the current user’s Music folder for example, run the following command:


This will get you to the pre-defined default music folder. So, if you have changed the library’s folder, this will unfortunately not work.

A library’s default folder can be accessed programmatically by using IShellLibrary interface, but that is out of the scope of my original question. It seems that the best approach is to either:

  1. Manually map enviroment variables to their known path
  2. Or manually map environment variables using their GUID. The advantage here is that you make it a system variable and have it work for all users).

Method 2

If you want %music% to point to your music folder then you just add a new environmental variable to your system.

If you want to %Libraries% point to your libraries then make a shortcut on c:\, for example, and then create a new environmental variable pointing to your c:\libraries shortcut. (but entering directly into sub-folders will not work, but you can create a new variable for those that are in Libraries)

You can then call them both from run with %music% or %Libraries%

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply