Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to add and remove Library locations from Windows 7's "Library" locations in for each of my users.

While its easy to do this from the desktop, and its easy to disable libraries appearing in explorer, how can I add or remove locations from a library location (e.g. remove c:\users\public\documents from the user's documents library)?

I don't need to 'lock' their list of library locations, I'm happy for them to add and remove their own locations as they wish, but I want to control the initial locations that they are offered.

share|improve this question
    
Added this question & answer to document something I found difficult to solve, so that it might help others. I'm still very much interested to hear of any other methods, especially easier ones, that I've missed! –  RobM Mar 8 '12 at 11:21
1  

2 Answers 2

up vote 11 down vote accepted

The Windows 7 libraries are actually just XML files with some clever shell extensions managing them. They're all called [Library_Name].library-ms (E.g. Pictures.library-ms) and can be opened in any text editor such as notepad by dragging and dropping.

The files can then be published using any normal mechanism - scripts, Group Policy Preferences etc.

There are a couple of things that I discovered, which you should be aware of:

  • The XML stores information about the user who is using the library file

  • Windows will automatically update / overwrite the XML when you double click on it / manipulate it. This is especially problematic as an administrator where double clicking will make your file unusable for users

  • If you make the file read only, this will have the effect of making the library appear read only, therefore preventing users from saving.

After some trial and error, I developed some 'blank' templates using the default Libraries which I'l post below.

You can use the following known folders guide to customise new default locations:

http://msdn.microsoft.com/en-us/library/bb882665.aspx

And I have found the following to be useful references regarding the library architecture:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd798389(v=vs.85).aspx http://msdn.microsoft.com/en-us/magazine/dd861346.aspx

Essentially, though, the way I found best to experiment was to simply make changes using the GUI and examine what is changed.

Documents

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
  <name>@shell32.dll,-34575</name>
  <version>20</version>
  <isLibraryPinned>true</isLibraryPinned>
  <iconReference>imageres.dll,-1002</iconReference>
  <templateInfo>
    <folderType>{7d49d726-3c21-4f05-99aa-fdc2c9474656}</folderType>
  </templateInfo>
  <propertyStore>
    <property name="HasModifiedLocations" type="boolean"><![CDATA[false]]></property>
  </propertyStore>
  <searchConnectorDescriptionList>
    <searchConnectorDescription publisher="Microsoft" product="Windows">
      <description>@shell32.dll,-34577</description>
      <isDefaultSaveLocation>true</isDefaultSaveLocation>
      <isDefaultNonOwnerSaveLocation>true</isDefaultNonOwnerSaveLocation>
      <isSupported>true</isSupported>
      <simpleLocation>
        <url>knownfolder:{FDD39AD0-238F-46AF-ADB4-6C85480369C7}</url>
      </simpleLocation>
    </searchConnectorDescription>
  </searchConnectorDescriptionList>
</libraryDescription>

Music

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
  <name>@shell32.dll,-34584</name>
  <version>12</version>
  <isLibraryPinned>true</isLibraryPinned>
  <iconReference>imageres.dll,-1004</iconReference>
  <templateInfo>
    <folderType>{94d6ddcc-4a68-4175-a374-bd584a510b78}</folderType>
  </templateInfo>
  <propertyStore>
    <property name="HasModifiedLocations" type="boolean"><![CDATA[false]]></property>
  </propertyStore>
  <searchConnectorDescriptionList>
    <searchConnectorDescription publisher="Microsoft" product="Windows">
      <description>@shell32.dll,-34577</description>
      <isDefaultSaveLocation>true</isDefaultSaveLocation>
      <isDefaultNonOwnerSaveLocation>true</isDefaultNonOwnerSaveLocation>
      <isSupported>true</isSupported>
      <simpleLocation>
        <url>knownfolder:{4BD8D571-6D19-48D3-BE97-422220080E43}</url>
        </simpleLocation>
    </searchConnectorDescription>
  </searchConnectorDescriptionList>
</libraryDescription>

Pictures

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
  <name>@shell32.dll,-34595</name>
  <ownerSID></ownerSID>
  <version>6</version>
  <isLibraryPinned>true</isLibraryPinned>
  <iconReference>imageres.dll,-1003</iconReference>
  <templateInfo>
    <folderType>{b3690e58-e961-423b-b687-386ebfd83239}</folderType>
  </templateInfo>
  <propertyStore>
    <property name="HasModifiedLocations" type="boolean"><![CDATA[false]]></property>
  </propertyStore>
  <searchConnectorDescriptionList>
    <searchConnectorDescription publisher="Microsoft" product="Windows">
      <description>@shell32.dll,-34577</description>
      <isDefaultSaveLocation>true</isDefaultSaveLocation>
      <isDefaultNonOwnerSaveLocation>true</isDefaultNonOwnerSaveLocation>
      <isSupported>false</isSupported>
      <simpleLocation>
        <url>knownfolder:{33E28130-4E1E-4676-835A-98395C3BC3BB}</url>
      </simpleLocation>
    </searchConnectorDescription>
  </searchConnectorDescriptionList>
</libraryDescription>

Videos

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
  <name>@shell32.dll,-34620</name>
  <ownerSID></ownerSID>
  <version>4</version>
  <isLibraryPinned>true</isLibraryPinned>
  <iconReference>imageres.dll,-1005</iconReference>
  <templateInfo>
    <folderType>{5fa96407-7e77-483c-ac93-691d05850de8}</folderType>
  </templateInfo>
  <propertyStore>
    <property name="HasModifiedLocations" type="boolean"><![CDATA[false]]></property>
  </propertyStore>
  <searchConnectorDescriptionList>
    <searchConnectorDescription publisher="Microsoft" product="Windows">
      <description>@shell32.dll,-34577</description>
      <isDefaultSaveLocation>true</isDefaultSaveLocation>
      <isDefaultNonOwnerSaveLocation>true</isDefaultNonOwnerSaveLocation>
      <isSupported>false</isSupported>
      <simpleLocation>
        <url>knownfolder:{18989B1D-99B5-455B-841C-AB7C74E4DDFC}</url>
       </simpleLocation>
    </searchConnectorDescription>
  </searchConnectorDescriptionList>
</libraryDescription>
share|improve this answer
2  
For those wondering where they're stored, they can be found under %APPDATA%\Microsoft\Windows\Libraries –  Agent_9191 Mar 8 '12 at 13:56

The only method I've found is to use the Windows 7 Powershell extentions for Libraries, available from codeplex here.

This can be used in a login script (it needs to run for each user, in their context), and it includes methods for adding and removing library locations.

Sample code

Import-Module "\\myserver\location\Windows7Library\Windows7Library.psm1"
# Before we can use the new commands from this module, it needs to be imported.

add-LibraryFolder -LibraryPath (Get-KnownFolder "VideosLibrary").path -FolderPath "\\borehamwood\dvds"
# add location to video library
#
Remove-LibraryFolder -LibraryPath (Get-KnownFolder "DocumentsLibrary").path -FolderPath "C:\users\Public\Documents"
Remove-LibraryFolder -LibraryPath (Get-KnownFolder "MusicLibrary").path -FolderPath "C:\users\Public\Music"
# remove locations from both the documents, and then the music library.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.