Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

%APPDATA%\Mozilla\Firefox

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

%LIBRARIES%\Music\
%MUSIC%\

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.

share|improve this question
up vote 2 down vote accepted

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:

libraries\music

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:

knownfolder:{4BD8D571-6D19-48D3-BE97-422220080E43}

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).
share|improve this answer
    
Thanks for sharing. Good to know! – andySF Feb 6 '11 at 9:21

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%

share|improve this answer
    
Indeed, this is probably the best workaround. I went ahead and defined %MUSIC%, as that is what piqued my interest. Still, I find the lack of variables odd. There doesn't even seem to be %DOCUMENTS% – zourtney Feb 2 '11 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .