Administratively Create and Modify Windows 7 Libraries


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

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

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:

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

Share It!

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.
Thank you very much ! This tool is very useful !
Cheers :)
Your help is much appreciated. Fantastic tool.

[Admin edit: removed spam link]
Edited on Friday, February 11 2011 @ 04:57 PM EST by Admin
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:

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.
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.

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.
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.
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
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.
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.
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 Tuesday, September 25 2012 @ 12:46 AM EDT by Seker
An immense moonlike of commendation, reserve it rental Fort Lee
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

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:
ls /home/law/Documents/samba
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 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 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...;-)



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.)
Thanks for the tutorial. It is an informative article about Administratively Create and Modify Windows 7 Libraries. There are many things we need to know and it si good to have such ideas that help the people to find out the solutions to our problems.Other than libraries and for the student's help write my research paper is great and students rely on it.
People caring for small children, elderly parents or family members with a disability; employees facing an illness or managing a disability; and workers involved as community volunteers may all need flexibility at work Personal loans for 5000
In this case you will begin it is important, it again produces a web site a strong significant internet site: Logo designs
With so many information in this site I hope admin is keeping himself busy with the development of this site Male Enhancement Pills
I think you’ve nailed it! would you mind updating your blog with more information?asset search san diego
Cool website buddy I am gona suggest this to all my list of contacts.internet privacy
Unbelievable job mates, I enjoy going through your articles.elantra 2016
Your contents force out your readers for commenting.Autos Nuevos
Contact me if you want help in updating your computer with window 8. Erect on Demand By Josh Harding
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.jesse young credico
You can download the latest tips from our download session. The Diabetes 60 System Review
I am opening a library online so i need an administrator. breast enlargement
What is the syntax for the setattrib subcommand?