Arabic Bulgarian Catalan Chinese Simplified Chinese Traditional Croatian Czech Danish Dutch Filipino Finnish French German Greek Hebrew Hindi Indonesian Italian Japanese Korean Latvian Lithuanian Norwegian Polish Portugese Romanian Russian Serbian Slovak Slovenian Spanish Swedish Ukrainian Vietnamese 

Administratively Create and Modify Windows 7 Libraries

Solutions

Libraries are one of the cool new things about Microsoft Windows 7. Unfortunately, Microsoft hasn't included any administrative tools for the handling of them so system administrators can't easily configure or create them using logon scripts. In addition, at the moment there are no Group Policy settings (or Preferences) that can let admins set up libraries. Hopefully these features will be added in the future, but until then there are still a couple ways to customize and deploy custom libraries. Continue on for a review of the most promising options and also grab a couple of our downloads to assist you...

[Note: Download links are at the end of the article]


First of all, I wanted to explain that a library file is really just a system file with a .library-ms file extension (similar to how shortcuts are really just .lnk files). They contain in XML format the properties of the library and also what folders are to be included in the library. They can be placed anywhere, but the default location is at %userprofile%\AppData\Roaming\Microsoft\Windows\Libraries. Therefore, Microsoft's official method of creating a custom library is to create or edit a Library Description (*.library-ms) file directly. Fortunately, there is also the IShellLibrary Interface that contains a number of methods for playing with libraries. If you look around, there are a few places where Microsoft provides sample code that uses this interface, and I've compiled a couple of them and made them available for download (allowed via the MSDN Code Gallery Licenses). It's a bit of a step backwards compared to Group Policy, but at the very least the utilities allow you to work with libraries from the command line, batch files, or scripts. Let's now go over these options in some more detail.
 

Option 1: Create or Edit a Library Description File Directly

I won't go into the details of editing a library description file directly, but Microsoft explains the schema here. It would probably be easier to create or modify a library file using the Manage Locations dialog box in Windows Explorer. Once you have the library file you want, you have a couple of options for deployment:

  1. Using a startup script or Group Policy Preferences to copy the library over to the Default User profile of your user workstations. The downside to this is that it would only affect new user profiles created when users log in for the first time.
  2. Using a logon script or Group Policy Preferences to copy the library over to your users' Libraries folder (or another location). A much better choice in my opionion compared to option 1, but has the downside that you cannot modify an existing library without overwriting any customized settings.
  3. If you are taking advantage of Roaming Profiles, you could place the library file in their profile on the server and when they log in it should pull it over. This would also work if you've redirected users' Appdata folders to a network share. This method has the same limitation as option 2.

Click here to learn how to customize default user profiles in Windows 7

Option 2: Use Windows Library Customization Utilities

As was already mentioned, Microsoft has released a bunch of code samples for developers to be able to work with libraries. We've already grabbed two of their sample projects and compiled them for you to use, saving you the trouble and also making sure you are using the correct code versions due to some requiring DLLs, missing certain features, etc. Both of these utilities allow you to create libraries, add or remove folders to or from existing libraries, set the default save folder, etc. There are some minor feature differences that may make you use one over the other, so you'll want to check them both out and see which one works best for you.


The first one is the Shell Library Command Line (ShLib.exe), which is a command-line console application for the IShellLibrary interface. The nicest thing about this utility is that it allows you to create libraries outside of the default library location by specifying a path, something that the other utility cannot do. The biggest issue with shlib.exe is that it is less polished than you would like and the command line syntax is hard to figure out, even with the built-in help references. Because of that we will post sample lines so you can get an idea of how to use it to perform the most commonly wanted functions.

Main ShLib.exe commands
shlib_command_line_options

Note that the .library-ms extension is optional only for the "create" command; all other commands must include the file extension.Create "Recipes" Library: shlib create "%userprofile%\AppData\Roaming\Microsoft\Windows\Libraries\Recipes.library-ms"

Add Folder to Library: shlib add "%userprofile%\AppData\Roaming\Microsoft\Windows\Libraries\Recipes.library-ms" "C:\Demo\Baking Recipes"

Delete Folder from Library: shlib remove "%userprofile%\AppData\Roaming\Microsoft\Windows\Libraries\Recipes.library-ms" "C:\Demo\Baking Recipes"

Set Default Save Location: shlib setsaveloc "%userprofile%\AppData\Roaming\Microsoft\Windows\Libraries\Recipes.library-ms" "C:\Demo\Pastry Recipes"
The default save location must be one of the folders already included in the library.  This is the folder that Explorer and other applications will use when saving items into the library.  Since libraries can be shared with other users, each library has a "private" and a "public" save location, which take effect for the owner of the library, and other users, respectively. Since the command above does not specify private or public (though you can), it will detect which save location to set based on the current user and the owner of the library.Delete Library (just delete the file): del "%userprofile%\AppData\Roaming\Microsoft\Windows\Libraries\Recipes.library-ms"

If you need further help, check out the sample Library_Demo.bat batch file included with the utility.



The second utility we've made available is the Shell Libraries Utility (SLUtil.exe). This is easier to use than ShLib.exe, but we haven't found a way to make it create or modify libraries outside of the default Libraries folder. In addition, it requires the C++ Redistributable Package to be installed to work.

Main SLUtil.exe commands
slutil_command_line_options


Create "Recipes" Library: slutil create Recipes

Add Folder to Library: slutil addfolder Recipes "C:\Demo\Baking Recipes"

Delete Folder from Library: slutil removefolder Recipes "C:\Demo\Baking Recipes"

Set Default Save Location: slutil savefolder Recipes "C:\Demo\Pastry Recipes"

Delete Library: slutil delete Recipes

As you can see, the commands are much easier to figure out, it being both good and bad that you just specify the library name and it assumes you are working with the default Library folder in the user's profile. If that's all you want to do, and you already have installed or can deploy the C++ distributable, I recommend the Shell Libraries Utility. If you need to specify an alternative location for your libraries or don't want to have to mess with runtime components, go with the Shell Library Command Line.
 

Final Thoughts

We at The Grim Admin hope this helps you customize libraries in your computing environment. One final warning I want to point out is you should make sure that your login scripts only run these utilities after checking that your operating system is Windows 7. Running these on an older version of Windows will pop up a shell32.dll error message. Feel free to use our sample batch file for detecting your current OS.

As always, feel free to post comments with your thoughts or suggestions! The downloads and other relevant links can be found below.

 

Links and Resources

  • Download Shell Library Command Line & Shell Libraries Utilities
  • Windows7Library for PowerShell: If you want to play with a PowerShell version here's the link
  • Win7 Library Tool: While you can adjust all these settings with the command-line utilities, if you're looking for a GUI to do any of the following this works well:
    • Add network (UNC or mapped drive) and any other un-indexed folders to libraries.
    • Backup library configuration, such that a saved set of libraries can be instantly restored at any point (like after a re-install of the OS or for transfer between multiple computers).
    • Create a mirror of all libraries (using symbolic links) in [SystemDrive]:libraries.  This means you can reference all your files using a much shorter path, and also provides another entry-point to your files in many places in the Operating System (e.g., file open/save dialogs).
    • Change a library’s icon.
    • Website: http://zornsoftware.talsit.info/?p=3

Tags: microsoft microsoft windows windows 7 windows libraries powershell group policy

Trackback

Trackback URL for this entry: http://www.grimadmin.com/trackback.php/creating-modifying-windows-7-libraries

Here's what others have to say about 'Administratively Create and Modify Windows 7 Libraries':

Controlling Libraries with Group Policy
[...] version): Shell Libraries | Windows 7 Online Training | Learn | Channel 9 I also compiled them with some explanation here for convenience (links at end of article) Hope this is useful. I'm glad I found these forums, though, as it looks like a [...] [read more]
Tracked on Thursday, April 22 2010 @ 12:35 PM EDT

Anything about IT » Blog Archive » ToolTip: Win7 Library Tool
[...] A nice FREE Tool to manage Windows 7 Libraries. Download from here I also recommend reading Administratively Create and Modify Windows 7 Libraries. var a2a_config = a2a_config || {~; a2a_config.linkname="ToolTip: Win7 Library [...] [read more]
Tracked on Sunday, May 16 2010 @ 09:51 AM EDT

remove location from library automation? | Resellernews.com.au
[...] on 06/03/2010 at 2:06:32 PM by wlazaraQuote:I ended up using shlib.exe found here:http://www.grimadmin.com/article.php/creating-modifying-windows-7-librariesFrom → Small Business Server Comments are closed. Categories Latest News [...] [read more]
Tracked on Thursday, June 03 2010 @ 04:14 PM EDT

Windows 7 Libraries - Default location?? - Multiplay Forums
[...] As far as I know these aren't configurable in group policy yet, but I could be wrong. There are some solutions here that may suit you. __________________ Thanks, Adam Reece | Multiplay Online Sven Co-op community liaison WWW: [...] [read more]
Tracked on Thursday, April 21 2011 @ 06:01 AM EDT

Annoying Restrictions message
[...] Wirral Posts 674 Thank Post 50 Thanked 59 Times in 55 Posts Rep Power 27 I used this Administratively Create and Modify Windows 7 Libraries - The Grim Admin to edit the libraries. Although I have stopped using them, as I found it was just a [...] [read more]
Tracked on Friday, October 14 2011 @ 03:21 PM EDT

Bloody Libraries!
[...] Posts Rep Power 28 I used these tools to redirect the Libraries to somewhere useful Administratively Create and Modify Windows 7 Libraries - The Grim Admin As, I have found it is possible to change the default save location on the 'Documents' [...] [read more]
Tracked on Tuesday, March 13 2012 @ 03:51 PM EDT

Itinéraire numérique » Shlib , ou comment manager les bibliothèques Documents et Images
[...] est à remplacer par %USERPROFILE%         Disponible en téléchargement sur : http://www.grimadmin.com/article.php/creating-modifying-windows-7-libraries    Main ShLib.exe commandes Categories: Non classé Tags: Commentaires (0) Trackbacks (0) [...] [read more]
Tracked on Saturday, May 19 2012 @ 09:35 AM EDT

Itinéraire numérique » Shlib , ou comment manager les bibliothèques Documents et Images
[...] est à remplacer par %USERPROFILE%         Disponible en téléchargement sur : http://www.grimadmin.com/article.php/creating-modifying-windows-7-libraries    Main ShLib.exe commandes Categories: Non classé Tags: Commentaires (0) Trackbacks (0) [...] [read more]
Tracked on Saturday, May 19 2012 @ 09:38 AM EDT

A Better Way to Customize the Windows Default Profile | Aaron Parker
[...] also needs to be run at first logon (and won’t work via CopyProfile). This article, Administratively Create and Modify Windows 7 Libraries, covers the use of ShLib.exe quite well. Implementing a Script to Modify the Default [...] [read more]
Tracked on Saturday, December 28 2013 @ 04:22 AM EST

A Better Way to Customize the Windows Default Profile | Aaron Parker
[...] also needs to be run at first logon (and won’t work via CopyProfile). This article, Administratively Create and Modify Windows 7 Libraries, covers the use of ShLib.exe quite well. Implementing a Script to Modify the Default [...] [read more]
Tracked on Saturday, December 28 2013 @ 04:27 AM EST

21 comments

The following comments are owned by whomever posted them. This site is not responsible for what they say.
In using this, I realized you don't want to use the %userprofile%\AppData\Roaming combination if you've redirected your Application Data folder outside of the user profile. Rather, you should use the %appdata% variable.
Authored by: Anonymous User on Saturday, September 11 2010 @ 09:09 PM EDT Administratively Create and Modify Windows 7 Libraries
Thank you very much ! This tool is very useful !
Cheers :)
Authored by: Anonymous User on Sunday, January 23 2011 @ 11:12 AM EST Administratively Create and Modify Windows 7 Libraries
Your help is much appreciated. Fantastic tool.

[Admin edit: removed spam link]
Edited on Friday, February 11 2011 @ 01:57 PM EST by Admin
Authored by: Jenny on Tuesday, May 03 2011 @ 10:51 AM EDT Administratively Create and Modify Windows 7 Libraries
Thanks for the info and the tools. I've used them to make the required changes to the library file but I can't use Group Policy Preferences to copy the library file to the target computer. When I try to select the file, it opens the library, taking me to the destination folder. I don't really want to use startup scripts... Any ideas?
Just paste in the path, making sure you use the ".library-ms" file extension. Example for a library called "TestLib":

Source File: \\Server1\Libraries\TestLib.library-ms
Destination File: C:\Users\Default\AppData\Roaming\Microsoft\Windows\Libraries\TestLib.library-ms

Note that you can also use variables, so your destination could be:
%userprofile%\AppData\Roaming\Microsoft\Windows\Libraries\TestLib.library-ms

If you used a Computer Configuration policy, it would put it in the Default user library location. If you used a User Configuration policy, it would put it in the Default user library location as well, unless you check the "Run in logged-on user's security context" option. In that case it would put in in that particular user's default Library location.
Authored by: Anonymous User on Monday, June 06 2011 @ 07:19 AM EDT Administratively Create and Modify Windows 7 Libraries
It's just not working as expected )-: I've created a default library-ms and a GPP to put it in the right location.

When there is no profile it works OK, the user gets the default library, but when the user changes the library he's not getting the default version back on logoff/logon or GP refresh. Even when update, create or first delete is used in the GPP.

When the user manually deletes the library he gets the right one back on logoff/logon

GPP shows no error.

It seems to me GPP's cannot update / handle .libray-ms files properly.

I haven't tested the exact circumstance you're running into, but I'm surprised that it doesn't work. The first thing I would check is to make sure that you're running in the "logged-on user's security context" and then I would try using the Replace action (the Create action won't replace the file if it already exists):

Create: Copy a file (or multiple files in one folder) from a source location to a destination location if it does not already exist at the destination, and then configure the attributes of those files for computers or users.

Replace: Delete a file (or multiple files in one folder), replace it with another file or files, and configure the attributes of those files for computers or users. The net result of the Replace action is to overwrite the files at the destination location. If the file does not exist at the destination, then the Replace action copies the file from the source location to the destination.

Update: Modify settings of an existing file (or multiple files in one folder) for computers or users. This action differs from Replace in that it only updates file attributes defined within the preference item. All other file attributes remain as configured on the file. If the file does not exist, then the Update action copies the file from the source location to the destination.

Authored by: Chris on Tuesday, August 09 2011 @ 10:52 AM EDT Administratively Create and Modify Windows 7 Libraries
I hope some1 still reads this :O
I got a problem, im running shlib on win7 6.1.4.
I can create my Library and I can use all the other commands, (even remove a folder when i manually added it.)
But I cannot add a folder to my library via console, which means by using the shlib add command.
Hoping for help.
Greetings,
chris
It's hard to say what the issue is. Is there any error message? Make sure you include the ".library-ms" file extension and I recommend putting the path in quotes. Don't include the trailing backslash. I'm assuming you're already doing all this since you said you were able to remove the folder from the library. Possibly a permissions issue. Any special or odd characters in the path? If all else fails, you can try SLUtil.exe.
Authored by: chris on Monday, August 15 2011 @ 08:42 AM EDT Administratively Create and Modify Windows 7 Libraries
Thanks for your answer.
There is nothing exceptional in the path and sadly I am using the library-ms
extention. Still wont get it to work. SLUtil isnt working for several permission reasons.
But nvm I coded some stuff arround shlib to make it work with some user input.
thx anyways
Authored by: Anonymous User on Friday, June 01 2012 @ 12:15 PM EDT Administratively Create and Modify Windows 7 Libraries
I've noticed that shlib.exe stops responding (Win7 dialog comes up for that & trying to find a solution) when the user profile folder is in the form of "username.DOMAINNAME"

This would only occur if there were a local account with the same username & the domain user of the same name logged in later (or vice versa I suppose).

It's been working fine for me when the user profile is just "C:\Users\username" without a domain/machine name identifier.
Authored by: Anonymous User on Wednesday, August 08 2012 @ 05:23 PM EDT Administratively Create and Modify Windows 7 Libraries
Follow up: turns out I was wrong about that. At the time of the above post, it was true, I was only seeing those errors for accounts with "C:\Users\username.DOMAINNAME" profile paths. But I've since been seeing it with regular "C:\Users\username".

Initially it seemed that opening up the permissions to the folder that the shlib.exe file is saved in prevented that (and it did on some PCs). I have since seen it come up on other PCs despite the user running the script having Full Control permissions on the executable.

The problem seems to be local, but whatever it is the shlib.exe is sometimes coming across an error that isn't being caught so it can exit gracefully.
Authored by: Anonymous User on Wednesday, August 08 2012 @ 05:32 PM EDT Administratively Create and Modify Windows 7 Libraries
Hmm... just after posting - reset the Compatibility level on the exe made it work without error...

Weird part is that it's a Windows 7 system (obviously), and I set the compatibility level to "Windows 7"...
Interesting... does this still happen when you use the %appdata% variable instead?
Edited on Monday, September 24 2012 @ 09:46 PM EDT by Seker
Authored by: Anonymous User on Thursday, May 22 2014 @ 01:42 AM EDT Administratively Create and Modify Windows 7 Libraries
Authored by: Anonymous User on Tuesday, June 12 2012 @ 09:46 AM EDT Push Library to new profiles
One other option not mention here is to prepare a library and put it into network default profile (in a windows domain environment) \\domain\SYSVOL\domain.level1domain.rootdomain\scripts\Default User.v2
Authored by: Astara on Thursday, August 02 2012 @ 09:50 PM EDT Administratively Create and Modify Windows 7 Libraries

Got a pointer to this article off of an MS post about problems with win7 indexing my Samba Drives. It doesn't. Using the tools posted, I see some of my previous efforts to get things in the library ... example:

Docs library:

/prog/Library(Windows) progs> slutil listfolders Documents
Folder list of Documents library:
C:\Users\law\Documents
C:\Users\law\Documents\Samba
C:\Users\law\Documents\tests
ls /home/law/Documents/samba
DomainControllerDNSrecords.txt
....
Well-known SIDs.htm

----

There were some directories and such but I though trying to search for a filename like DomainControllerDNSrecords.txt -- it should come back in a flash -- at the top of the tree.... etc...It never found it..(maybe it would have if I had gone to eat or something..

Same thing in pictures... I had it list my pictures lib -- top level directory displayed in a flash.... but NOTHING

below.   Nothing below any directory was listed in any index -- and required exhaustive realtime search.

Some things it had in it's directory that I didn't put it --- all of my top level dirs on my server (it's open to me as my server is my windows workstation's "back-end" -- waiting with baited breath for 10Gb network cards and hubs to drop into consumer range, as you never get top speed for most things -- random access -- but even explorer will regularlly get 80-100MB/s... top in large transfers 125MB/s writes, 119MB/s reads.. 

Unfortutunately, many apps don't achieve a fraction of that -- like login/logout -- with Adobe dumping 3G of help files into the user profile dir and Mozilla Tbird using the roaming profile as a download 'cache' for my IMAP server (can you say Idiots?)... by default in TB3 and above, they try to download ALL of your remote email to cache it locally so they can index it quickly...Um...my IMAP store used to have about 4-5G in it...Tbird use either 4k or 8k writes for writing to the network as well as to local files (boy did people with remote mounted home dirs suffer!)...  But
longest logout time i've waited for was about 50 minutes and login... about 25...

Anyway -- Explorer manually searching for files over the net while I am waiting -- let alone indexing content -- abysmal.    in WinXP, I'd let it's indexer index my entire network HD's every night..... was great for searching and finding things.....

But now...well... still looking for solutions... have a feeling it will be when somone (me?...not likely the time), writes a native indexer to run on the target machines that the win desktop search will query for remote content... it's just that now workstations can't index their remote files....

In case you missed the humor, MS's marked it's own answer -- to allow you remote content to be cached in offline files -.. Right... <100GB free on my local HD, to cache 30TB of files?....right.

Anyway, Thanks for the tools...my main Q was how to get Windows to automatically explore subdirs, but I don't think it will do that on a network disk...(heck it doesn't even index the filenames in the named lib directories!)....

Oh well...something else to play with in my copious free time (*cough* *choke*)....excuseme something caught in my throat...oh...copious and free time...well, maybe not...;-)

 

 

Authored by: Anonymous User on Wednesday, August 14 2013 @ 11:08 AM EDT Administratively Create and Modify Windows 7 Libraries
Authored by: palang on Saturday, May 03 2014 @ 04:23 AM EDT Administratively Create and Modify Windows 7 Libraries
Kenapa anda belum paham dengan cipto junaedy yang kami rangkai info cipto junaedy nya disini dan telah banyak yang terbantu dengan kehadiran artikel dahsyat yang satu ini. Percayalah ini bukanlah hal yang diada-adakan
Authored by: Anonymous User on Sunday, May 04 2014 @ 03:03 PM EDT APPDATA
Hi, Great tool!!! Thanks for sharing it!

You could correct the docs and examples just a little:
Instead of " %userprofile%\AppData\Roaming" it should say " %appdata%".

Also, it might work if the dlls from the redists are placed next to your executables to make it portable.
(I haven't tried that, though.)
Authored by: Anonymous User on Thursday, May 22 2014 @ 04:36 AM EDT Administratively Create and Modify Windows 7 Libraries
I don't really want to use startup scripts... paris en ligne

Advertisement