How can I manipulate Windows 7 Libraries via Group Policy?
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>
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.