Jump to content


  • 0
wimvv

Windows 7 users are missing library folders, need an automated fix

Question

SInce last week we are getting reports that are users are missing their library folders like "Documents","Music","Pictures",etc

 

After some troubleshooting it appears that the library folders that should exist under the roaming profiles

%appdata%\Microsoft\Windows\Libraries

doesn't exist. (and as a result all the *.library-ms files in that folder are missing)

 

Now opening the computer browser, and right click on libraries, select "Restore Default Libraries" does the trick, but can't be called a real solution since our students don't have roaming profiles and would be forced to execute this process time and time and time again on different computers.

 

Anyone has a commandline version on how to restore the folder and files for the libraries ?

 

Kind regards,

Wim

 

post-22112-0-40780000-1384788665_thumb.png

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Tried to use http://www.grimadmin.com/article.php/creating-modifying-windows-7-libraries#Links_Resources but for some reason the users didn't have enough rights to create the library.

 

Here is the script I made that allowed me to auto create the library-ms files for someone who is interested.

Option Explicit

Const ForReading 	= 1
Const ForWriting 	= 2
Const ForAppending 	= 8

Dim WshShell	: Set WshShell = CreateObject("WScript.Shell")
Dim objFSO	: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objTextFile
Dim iMainTeller, iError
Dim strProfilePath, strLibrary

strProfilePath = WshShell.ExpandEnvironmentStrings("%appdata%")
If Right(strProfilePath,1) <> "\" Then strProfilePath = strProfilePath & "\"

For iMainTeller = 1 To 4 
	Select Case iMainTeller
		Case 1 : strLibrary = "Documents"
		Case 2 : strLibrary = "Videos"
		Case 3 : strLibrary = "Music"
		Case 4 : strLibrary = "Pictures"
	End Select

	If Not objFSO.FileExists(strProfilePath & "Microsoft\Windows\Libraries\" & strLibrary & ".library-ms") Then 		
		
            If Not objFSO.FolderExists(strProfilePath & "Microsoft\Windows\Libraries") Then
                On Error Resume Next
                objFSO.CreateFolder(strProfilePath & "Microsoft\Windows\Libraries")
                Err.Clear
                On Error Goto 0
            End If

		On Error Resume Next
		Set objTextFile = objFSO.CreateTextFile(strProfilePath & "Microsoft\Windows\Libraries\" & strLibrary & ".library-ms",True)
		iError = Err.Number
		On Error Goto 0
		
		If iError = 0 Then 
		objTextFile.WriteLine("<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>")
		objTextFile.WriteLine("<libraryDescription xmlns=" & Chr(34) & "http://schemas.microsoft.com/windows/2009/library" & Chr(34) & ">")
		Select Case iMainTeller
    		Case 1 : objTextFile.WriteLine(vbTab & "<name>@shell32.dll,-34575</name>")
	    	Case 2 : objTextFile.WriteLine(vbTab & "<name>@shell32.dll,-34620</name>")
    		Case 3 : objTextFile.WriteLine(vbTab & "<name>@shell32.dll,-34584</name>")
    		Case 4 : objTextFile.WriteLine(vbTab & "<name>@shell32.dll,-34595</name>")
    	End Select 		    	    				
		' ownerSID will be added by Windows when first accessed
		objTextFile.WriteLine(vbTab & "<version>8</version>")  ' since no current version can be found a random one
		objTextFile.WriteLine(vbTab & "<isLibraryPinned>true</isLibraryPinned>")
		Select Case iMainTeller
			Case 1 : objTextFile.WriteLine(vbTab & "<iconReference>imageres.dll,-1002</iconReference>")
			Case 2 : objTextFile.WriteLine(vbTab & "<iconReference>imageres.dll,-1005</iconReference>")
			Case 3 : objTextFile.WriteLine(vbTab & "<iconReference>imageres.dll,-1004</iconReference>")
			Case 4 : objTextFile.WriteLine(vbTab & "<iconReference>imageres.dll,-1003</iconReference>")
		End Select
		objTextFile.WriteLine(vbTab & "<templateInfo>")	
		'http://msdn.microsoft.com/en-us/library/windows/desktop/dd798386%28v=vs.85%29.aspx
		Select Case iMainTeller
			Case 1 : objTextFile.WriteLine(vbTab & vbTab & "<folderType>{7D49D726-3C21-4F05-99AA-FDC2C9474656}</folderType>")
			Case 2 : objTextFile.WriteLine(vbTab & vbTab & "<folderType>{5fa96407-7e77-483c-ac93-691d05850de8}</folderType>")
			Case 3 : objTextFile.WriteLine(vbTab & vbTab & "<folderType>{94d6ddcc-4a68-4175-a374-bd584a510b78}</folderType>")
			Case 4 : objTextFile.WriteLine(vbTab & vbTab & "<folderType>{B3690E58-E961-423B-B687-386EBFD83239}</folderType>")
		End Select		
		objTextFile.WriteLine(vbTab & "</templateInfo>")
		objTextFile.WriteLine(vbTab & "<searchConnectorDescriptionList>")
		objTextFile.WriteLine(vbTab & vbTab & "<searchConnectorDescription publisher=" & Chr(34) & "Microsoft" & Chr(34) & " product=" & Chr(34) & "Windows" & Chr(34) & ">")
		Select Case iMainTeller		' personal folder , volgende descriopt is public folder
    		Case 1 : objTextFile.WriteLine(vbTab & vbTab & vbTab & "<description>@shell32.dll,-34577</description>") 
		    Case 2 : objTextFile.WriteLine(vbTab & vbTab & vbTab & "<description>@shell32.dll,-34622</description>") 
    		Case 3 : objTextFile.WriteLine(vbTab & vbTab & vbTab & "<description>@shell32.dll,-34586</description>") 
    		Case 4 : objTextFile.WriteLine(vbTab & vbTab & vbTab & "<description>@shell32.dll,-34597</description>") 
    	End Select 	    					
		objTextFile.WriteLine(vbTab & vbTab & vbTab & "<isDefaultSaveLocation>true</isDefaultSaveLocation>")
		objTextFile.WriteLine(vbTab & vbTab & vbTab & "<simpleLocation>")
		'Know folders GUID : http://msdn.microsoft.com/en-us/library/bb882665.aspx
		Select Case iMainTeller
			Case 1 : objTextFile.WriteLine(vbTab & vbTab & vbTab & vbTab & "<url>knownfolder:{FDD39AD0-238F-46AF-ADB4-6C85480369C7}</url>")
			Case 2 : objTextFile.WriteLine(vbTab & vbTab & vbTab & vbTab & "<url>knownfolder:{18989B1D-99B5-455B-841C-AB7C74E4DDFC}</url>")
			Case 3 : objTextFile.WriteLine(vbTab & vbTab & vbTab & vbTab & "<url>knownfolder:{4BD8D571-6D19-48D3-BE97-422220080E43}</url>")
			Case 4 : objTextFile.WriteLine(vbTab & vbTab & vbTab & vbTab & "<url>knownfolder:{33E28130-4E1E-4676-835A-98395C3BC3BB}</url>")
		End Select		
		'serialized will be created by Windows when first accessed  http://msdn.microsoft.com/en-us/library/windows/desktop/dd940482(v=vs.85).aspx
		
		objTextFile.WriteLine(vbTab & vbTab & vbTab & "</simpleLocation>")
		objTextFile.WriteLine(vbTab & vbTab & "</searchConnectorDescription>")
		objTextFile.WriteLine(vbTab & vbTab & "<searchConnectorDescription publisher=" & Chr(34) & "Microsoft" & Chr(34) & " product=" & Chr(34) & "Windows" & Chr(34) & ">")
		Select Case iMainTeller
    		Case 1 : objTextFile.WriteLine(vbTab & vbTab & vbTab & "<description>@shell32.dll,-34579</description>") 
			Case 2 : objTextFile.WriteLine(vbTab & vbTab & vbTab & "<description>@shell32.dll,-34624</description>")
    		Case 3 : objTextFile.WriteLine(vbTab & vbTab & vbTab & "<description>@shell32.dll,-34588</description>") 
    		Case 4 : objTextFile.WriteLine(vbTab & vbTab & vbTab & "<description>@shell32.dll,-34599</description>") 
    	End Select 	
		objTextFile.WriteLine(vbTab & vbTab & vbTab & "<isDefaultNonOwnerSaveLocation>true</isDefaultNonOwnerSaveLocation>")
		objTextFile.WriteLine(vbTab & vbTab & vbTab & "<simpleLocation>")
		'Know folders GUID : http://msdn.microsoft.com/en-us/library/bb882665.aspx
		Select Case iMainTeller
			Case 1 : objTextFile.WriteLine(vbTab & vbTab & vbTab & vbTab & "<url>knownfolder:{ED4824AF-DCE4-45A8-81E2-FC7965083634}</url>")
			Case 2 : objTextFile.WriteLine(vbTab & vbTab & vbTab & vbTab & "<url>knownfolder:{2400183A-6185-49FB-A2D8-4A392A602BA3}</url>")
			Case 3 : objTextFile.WriteLine(vbTab & vbTab & vbTab & vbTab & "<url>knownfolder:{3214FAB5-9757-4298-BB61-92A9DEAA44FF}</url>")
			Case 4 : objTextFile.WriteLine(vbTab & vbTab & vbTab & vbTab & "<url>knownfolder:{B6EBFB86-6907-413C-9AF7-4FC2ABF07CC5}</url>")
		End Select		
		'serialized will be created by Windows when first accessed	 http://msdn.microsoft.com/en-us/library/windows/desktop/dd940482(v=vs.85).aspx
		objTextFile.WriteLine(vbTab & vbTab & vbTab & "</simpleLocation>")
		objTextFile.WriteLine(vbTab & vbTab & "</searchConnectorDescription>")
		objTextFile.WriteLine(vbTab & "</searchConnectorDescriptionList>")
		objTextFile.WriteLine("</libraryDescription>")
		objTextFile.Close
		End If
    End If
Next
    
Set objTextFile = Nothing
Set objFSO = Nothing
    

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.