Configuring Windows 7 Libraries using Group Policy Preferences

One of the most useful features in Windows 7 is Libraries. Unfortunately, it is also one of the most painful to administer in a domain. In an ideal world you'd be able to use Group Policy to add or remove whatever library locations you desired. However Microsoft seems to have forgot about Libraries when they updated Group Policy for Server 2008 R2 and Windows 7 as there is no Group Policy to control Libraries.

Thankfully, there is a solution! Using Group Policy Preferences, the library settings files can be copied over the existing library settings upon login allowing you to set your library to whatever location you want.

Locating the Library Files

The library files are located in C:\Users\Name\AppData\Roaming\Microsoft\Windows\Libraries\Library Name.library-ms and they won't show an extension unless you open them in a text editor. This can be tricky because they act as a shortcut so when you click on them you typically just end up at the location. I use Notepad++ and it has an option to Edit with Notepad++ in the context menu that allows me to get around this.

Simplifying the file

Microsoft provides detailed explanations on most of the tags and attributes that you should see in your .library-ms files. There are a few tags that should be cleared in order for the .library-ms file to be applicable to any user.

  • <ownerSID> - contains the owners security identifier (SID). I have verified it is inserted on the first load of the library.
  • <serialized> - contains a base64-encoded ShellLink pointing to the location defined in the <url> element. This is also updated on the first load of the library and should be left blank.

Sidenote: Although I'm not sure if the <ownerSID> tag must be cleared, I can verify it is recreated in my environment (SBS 2011 and W7 Pro). The <serialized> tag on the other hand definitely must be cleared, Microsoft states this at http://msdn.microsoft.com/en-us/library/windows/desktop/dd940482(v=vs.85).aspx and I have experienced it causing the incorrect path to be added to the library first hand.

Creating the Group Policy Preference

The following steps should be sufficient to create the necessary Group Policy. If you want to remap Documents, Music, Pictures, and Videos you will need to create four different File rules.

  • Create a new Group Policy and go to the User Configuration / Preferences / Windows Settings / Files and create a new file.
  • Set the Action to Replace and manually type the path or at least the filename into the Source field.
  • In the Destination field enter the following %userprofile%\Appdata\roaming\Microsoft\Windows\Libraries\Library Name.library-ms
  • Switch over to the Common tab and check the Run in logged-on user's security context (user policy option) this is important as the group policy will now use the user's environmental variables

You should now be ready to go! Run gpupdate /force on a client computer and logoff if it asks you to. When you log back on you should see your new library locations.

My library locations

Here are the library locations I am currently using on one of my networks.
<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>@shell32.dll,-34575</name>
<version>4</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[true]]></property>
</propertyStore>
<searchConnectorDescriptionList>
<searchConnectorDescription>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<isSupported>true</isSupported>
<simpleLocation>
<url>\\sbsserver\Public\Documents</url>
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>@shell32.dll,-34584</name>
<version>2</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[true]]></property>
</propertyStore>
<searchConnectorDescriptionList>
<searchConnectorDescription>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<isSupported>true</isSupported>
<simpleLocation>
<url>\\sbsserver\Public\Music</url>
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>@shell32.dll,-34595</name>
<version>2</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[true]]></property>
</propertyStore>
<searchConnectorDescriptionList>
<searchConnectorDescription>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<isSupported>true</isSupported>
<simpleLocation>
<url>\\sbsserver\Public\Pictures</url>
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>@shell32.dll,-34620</name>
<version>2</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[true]]></property>
</propertyStore>
<searchConnectorDescriptionList>
<searchConnectorDescription>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<isSupported>true</isSupported>
<simpleLocation>
<url>\\sbsserver\Public\Videos</url>
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>

Comments

Thanks .

I've been trying to figure this out for a month. Everyone says it can be done but nobody ever gives you the full story. You not only told me what I needed to know, you even gave me a tool to do it with! I did have to figure out that the easiest way to load *.Library-MS into an editor is browse to the library, right click on the location that I want to edit and click Open With. But since I knew that Notepad++ was supposed to work it wasn't that hard to figure out. Thank You! Thank You! Thank You!

Glad to hear this helped. Like you, I was sick of everyone saying it couldn't be done so I figured out how and posted this. Please refer the doubters here!

I had figured out how to remove the public documents from the library by updating this file and sending it out through GP Prefs but some people where seeing an error where the file was pointing to my admin account when they first clicked on Documents. I did not know to remove the OwnerSID and Serialized tags. Thanks for giving a full explantion on this.

This is a great help for people struggling with this issue. It was the first time for me and you have cut down on my R & D time tremendously. I suspected it might have something to do with the libraries but I didn't know how to start. I just made all my changes and I will now test. I used a little trick to edit the files. I accessed them from the share from another machine Windows XP but I think it will work from others. Textpad works for me. Thanks Kevin. I really appreciate your posting.

Does this replace the library files on every login or only once?
If it's replaced everytime, changes made by the users are lost, aren't they? In this case: Is there a way to keep user made addtions?

All this does is overwrite the built in libraries. If someone customizes the built in libraries then their customizations will not be preserved.

If they go and make a new library then that will be untouched.

But I think it could be customized to run only once.

Thanks for posting this information. There don't appear to be any changes between Windows Server 2008 R2 and 2012 as everything you wrote applies identically in 2012. Windows 8 behavior is a little different but I don't have enough experience with it to know why yet. The special folders don't appear in my libraries on my Windows 8 box but the network shares still do. If I figure it out I will let you know.

If you do find any Windows 8 / Server 2012 info just let me know. I have yet to play around with either of them but hopefully will get to soon.

Actually, the special folder problem I'm running into isn't just Windows 8. It's happening on 7 as well. I probably missed something in your instructions because they only appear for me and I created the initial library files under my account. I hope to get it worked out this weekend. I am also upgrading a couple more computers to Windows 8 so I should have some accurate test results for you.

If you want to reference special folder (My Documents, My Pictures, etc.) in your GPO libraries you need to remove the "propertyStore" node with the "MachineGUID" property under the "searchConnectorDescription" node for the special folder. I just commented it out in my files just in case it had something important. The example below shows the commented out section to make it easy for you to see.

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>@shell32.dll,-34575</name>
<ownerSID></ownerSID>
<version>33</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[true]]></property>
</propertyStore>
<searchConnectorDescriptionList>
<searchConnectorDescription publisher="Microsoft" product="Windows">
<description>@shell32.dll,-34577</description>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<simpleLocation>
<url>knownfolder:{FDD39AD0-238F-46AF-ADB4-6C85480369C7}</url>
<serialized></serialized>
</simpleLocation>
<!--
<propertyStore>
<property name="MachineGUID" type="guid"><![CDATA[{C7771832-BD39-4047-9D14-22917862E574}]]></property>
</propertyStore>
-->
</searchConnectorDescription>
<searchConnectorDescription>
<isSupported>true</isSupported>
<simpleLocation>
<url>\\myServer\Documents</url>
<serialized></serialized>
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>

Thanks this really helps a lot.
http://www.ballardcomputer.com

Hi Kevin

I just tried your solution. I am getting an error. Here is my documents.libary-ms. I am trying to change Documents under Libraries to point to each users SkyDrive Pro on Office 365. I tried to follow your first example to a tee but getting the error. Any help is appreciated!
<?xml version="1.0" encoding="UTF-8"?>

@shell32.dll,-34575
2
true
imageres.dll,-1002

{7d49d726-3c21-4f05-99aa-fdc2c9474656}

true
true

https://americanacademy-my.sharepoint.com/personal/%username%_americanac...

<?xml version="1.0" encoding="UTF-8"?>
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>@shell32.dll,-34575</name>
<version>2</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[true]]></property>
</propertyStore>
<searchConnectorDescriptionList>
<searchConnectorDescription>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<isSupported>true</isSupported>
<simpleLocation>
<url>https://americanacademy-my.sharepoint.com/personal/%username%_americanac...
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>

I am trying to add the users home folder to their library. is the a way to make the tag include an environment variable like %USERNAME% ? I tried this and it didnt appear to work.

Hi, thank's for the good documentation! One problem I have ist that - I supose after a policyupdate with open explorer which happens default by microsoft the explorer the xml file is copied over to the user profile again. In that case explorer has problems when browsing to anothe folder. As the gpupdate overwrites the persisitng xml file it then has no key anymore in it.
Any other people having this issue?
Regards

Where should the source files be saved?

Hi, and thank you for the information! Where should the source files be saved?

Hi,
Is it possible to use a variable in the path (e.g. %temp%) to get to a location? I tried modding the xml, but once saved, it says no sources have been included.
Thanks

Thank you for this! Clearly some management Microsoft left out of Windows 7!

Wow!! Thanks

Great tut! I'm also wondering about using variables in locations though. \\server\username works, but \\server\%username% doesn't. If i cant use a variable, ill have to create a documents file for every user on the network, which kinda defeats the point of using a GPO to set locations in the first place.

Hi,

I had similar problem. I wanted to add a new folder in the user's profile to a new library. It turned out, that you can use the known folders for it. http://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx

In my case the url line was: knownfolder:{FDD39AD0-238F-46AF-ADB4-6C85480369C7}\Word

After deployment it worked fine!

Thanks for the information. Really a great help for my configuring Windows 7 libraries using this all group policy preferences. Keep posting interesting topics.

Hi guys.

Instead of all this hard work just use the GPO to hide explorer Frame pane.. Does the same job.

Shaun

http://www.sevenforums.com/tutorials/243472-details-pane-enable-disable-...

I just wanted to say thanks. That was a well written and informative piece of work.
http://www.ansonpc.com

Super Fun Time