Hi,
My issue is that in my roaming profile folder, there are 2 or 3 profile folders for each user, some obvious as they are marked with bad or old. However, I need to find out which is the actual profile folder used by the user so I can remove the others. I have been working with the script below and have not been able to get it to work correctly while reading a list of computer names. As it is currently written, the script only records the registry values for the last computer in the list. What am I missing?
' Set the constants
Const HKEY_LOCAL_MACHINE = &H80000002
Const ForAppending = 8
' Create FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile2 = objFSO.OpenTextFile("c:\profilelist.txt", ForAppending)
'Read the server list
Const ForReading = 1
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\computers.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.Readline
objDictionary.Add i, strComputer
i = i + 1
Loop
Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
objTextFile2.WriteLine("PC Name: " & strComputer)
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
strValueName = "CentralProfile"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strServerPath
If strServerPath <> "" then
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
'Wscript.Echo strValue & " is stored centrally on " & strServerPath
objTextFile2.WriteLine("Current CentralProfile Value: " & strServerPath)
END IF
Next
objTextFile2.WriteLine(vbCrLf)
objTextFile2.Close
Our community of experts have been thoroughly vetted for their expertise and industry experience.