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.
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
Music
Pictures
Videos
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