When deploying Windows 7 in enterprise environments, administrators often need to customize the default Library locations that users see upon first login. While Windows provides GUI methods for Library management, automating this through Group Policy requires a more technical approach.
The most effective method involves using Group Policy Preferences (GPP) to modify Library definitions. Here's a step-by-step implementation:
# Sample PowerShell to create Library manipulation XML
$libraryXML = @"
<libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library">
<name>Documents</name>
<isLibraryPinned>true</isLibraryPinned>
<iconReference>imageres.dll,-1002</iconReference>
<templateInfo>
<folderType>{7d49d726-3c21-4f05-99aa-fdc2c9474656}</folderType>
</templateInfo>
<searchConnectorDescriptionList>
<searchConnectorDescription>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<isSupported>true</isSupported>
<simpleLocation>
<url>%USERPROFILE%\Documents</url>
</simpleLocation>
</searchConnectorDescription>
<searchConnectorDescription>
<url>\\server\department_docs</url>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>
"@
$libraryXML | Out-File -FilePath "\\domain\sysvol\domain\Policies\{GUID}\User\Preferences\Libraries\Documents.library-ms"
To implement this through Group Policy:
- Create a new GPO or edit an existing one
- Navigate to User Configuration > Preferences > Windows Settings > Files
- Create a new File preference item with these settings:
- Action: Update
- Source file: \\path\to\your\custom.library-ms
- Destination file: %AppData%\Microsoft\Windows\Libraries\custom.library-ms
For more complex scenarios, consider using a startup script to modify libraries:
:: Batch script to remove Public Documents from user's Documents library
@echo off
set LIBRARY_PATH=%AppData%\Microsoft\Windows\Libraries\Documents.library-ms
:: Create backup
copy "%LIBRARY_PATH%" "%LIBRARY_PATH%.bak"
:: Remove Public Documents reference
powershell -Command "(Get-Content '%LIBRARY_PATH%') -replace '<url>%PUBLIC%\\Documents</url>', '' | Set-Content '%LIBRARY_PATH%'"
After deployment, verify the changes by:
- Checking the Library-ms files in %AppData%\Microsoft\Windows\Libraries
- Using Process Monitor to track Library-related registry and file operations
- Testing with a fresh user profile to ensure proper initial configuration
Windows 7 Libraries are actually defined by library description files (.library-ms) stored in %AppData%\Microsoft\Windows\Libraries
for each user profile. These XML files contain all the configured locations for each library. While the GUI makes it simple to modify these locations, automating the process through Group Policy requires a different approach.
The main obstacle is that library locations are per-user settings that get initialized during profile creation. We need to modify these settings before users log in for the first time, or deploy changes to existing profiles.
We'll use a combination of Group Policy Preferences (GPP) and PowerShell scripts to achieve this:
- Deploy modified library files via GPP Files
- Use logon scripts to modify existing profiles
- Optionally disable library management through Group Policy settings
1. Creating Modified Library Files
First, create template library files with your desired configurations:
<!-- Documents.library-ms -->
<?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>
<searchConnectorDescriptionList>
<searchConnectorDescription>
<isDefaultSaveLocation>true</isDefaultSaveLocation>
<isSupported>false</isSupported>
<simpleLocation>
<url>%USERPROFILE%\Documents</url>
</simpleLocation>
</searchConnectorDescription>
<!-- Add your custom locations here -->
<searchConnectorDescription>
<simpleLocation>
<url>\\server\department_docs</url>
</simpleLocation>
</searchConnectorDescription>
</searchConnectorDescriptionList>
</libraryDescription>
2. Deploying via Group Policy Preferences
Create a new GPO and navigate to:
User Configuration → Preferences → Windows Settings → Files
Configure the following settings for each library file:
- Action: Update
- Source file:
\\yourdomain\NETLOGON\Libraries\Documents.library-ms
- Destination file:
%AppData%\Microsoft\Windows\Libraries\Documents.library-ms
3. PowerShell Script for Existing Profiles
For existing users, use this PowerShell script to modify libraries:
# LibraryManagement.ps1
$librariesPath = "$env:APPDATA\Microsoft\Windows\Libraries"
$templatePath = "\\yourdomain\NETLOGON\Libraries"
# Backup existing libraries
Copy-Item "$librariesPath\*.library-ms" "$env:TEMP\LibraryBackup\" -Force
# Deploy new libraries
Get-ChildItem $templatePath -Filter "*.library-ms" | ForEach-Object {
Copy-Item $_.FullName $librariesPath -Force
}
# Refresh shell to apply changes
$shell = New-Object -ComObject Shell.Application
$shell.Windows() | Where-Object { $_.FullName -like "*explorer.exe" } | ForEach-Object {
$_.Refresh()
}
For more granular control, you can use the following registry settings:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoManageLibrariesFromThisPC"=dword:00000001
"NoAddingLibraryLocations"=dword:00000001
- Library files are sensitive to XML formatting - always validate before deployment
- Test changes with a small group before enterprise rollout
- Remember that changes won't appear until Explorer is restarted
- Check Event Viewer for Group Policy application errors