Workaround for KB2444193 with USMT 4

Posted on Updated on

There is a known issue when migrating to Windows 7 with USMT.  If a computer is deployed using an AutoUnattend.xml, then after migrating a user to the new computer, when the user launches IE they receive the message “A program on your computer has corrupted your default search provider…“.  One workaround is to have a script correct the SearchScope GUIDs for each user profile.  The script that I have written (below) simply mounts each user profile hive, then deletes the registry tree for the SearchScopes.  The effect is that when the user first launches IE 8, then it will pull the default Search Provider from HKLM defined in the deployed computer via AutoUnattend.

' NAME: DeleteUserIESearchProviders
' AUTHOR: Nick Moseley,
' COMMENT: Mounts user registry hives and deletes the IE Search Provider
' registry values.  This is to fix the issue caused by KB2444193
' 1.0 (06/23/2011) - Initial Script
Option Explicit
Const ForAppending = 8
Const HKLM = &H80000002
Const sUserKey = "Software\Microsoft\Internet Explorer\SearchScopes"
Dim oReg, oFSO, oFile, oUserSubkey, aUserProfiles, oShell
Dim sProfileLCase, sRegExe, sRegLoad, sRegUnload, sHiveName, sSubPath, sProfile, sValueName, sKeyPathUserProfiles, sValue, ReturnVal
Set oReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject ("Scripting.FileSystemObject")
' Prompt if OK to continue
Dim x
x = msgbox ("Click OK to delete the IE Search Provider for all user profiles", vbOKCancel, "Fix IE Search Provider")
If x<>1 Then
 WScript.Echo "Script Terminated"
End If
' Begin log file etnries
If Not oFSO.FileExists("C:\DeleteSearchProvider.log") Then
 oFSO.CreateTextFile "C:\DeleteSearchProvider.log"
End If
Set oFile = oFSO.OpenTextFile ("DeleteSearchProvider.log", ForAppending, True)
oFile.WriteLine "Delete IE Search Provider"
oFile.WriteLine "  => Began at " & Date & " " & Time
oFile.WriteLine "  => For each user profile, deleted HKCU\" & sUserKey
' Begin configuration of existing user profiles
sValueName = "ProfileImagePath"
sKeyPathUserProfiles = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
sRegExe = "C:\Windows\system32\reg.exe"
oReg.EnumKey HKLM, sKeyPathUserProfiles, aUserProfiles
' Existing User Profiles
Dim sHiveKeyPath
For Each oUserSubkey In aUserProfiles
    sSubPath = sKeyPathUserProfiles & "\" & oUserSubkey
    oReg.GetExpandedStringValue HKLM,sSubPath,sValueName,sValue
    sProfile = Split(sValue, "\")
    sProfileLCase = LCase(sProfile(2))
    If sProfileLCase = "system32" Then
     'oFile.WriteLine "  => Skipped user profile: system32"
    ElseIf sProfileLCase = "localservice" Then
     'oFile.WriteLine "  => Skipped user profile: localservice"
    ElseIf sProfileLCase = "networkservice" Then
     'oFile.WriteLine "  => Skipped user profile: networkservice"
    ElseIf sProfileLCase = "serviceprofiles" Then
     'oFile.WriteLine "  => Skipped user profile: serviceprofiles"
    ElseIf sProfileLCase = "administrator" Then
     'oFile.WriteLine "  => Skipped user profile: administrator"
    ElseIf sProfileLCase = "default" Then
     'oFile.WriteLine "  => Skipped user profile: default user"
     sHiveName = "TempHive_" & sProfileLCase
     ' Load user's profile hive into a temp location
     sRegLoad = " LOAD HKLM\" & sHiveName & " """ & sValue & "\ntuser.dat"""
     oShell.Run sRegExe & sRegLoad, 0, True
     ' Call subroutine to change registry key
  sHiveKeyPath = sHiveName & "\" & sUserKey
     DeleteSubkeys (sHiveKeyPath)
  oFile.WriteLine "  => Set user profile: " & sProfileLCase
     ' Unload user's profile hive
     sRegUnload = " UNLOAD HKLM\" & sHiveName
     oShell.Run sRegExe & sRegUnload, 0, True
    End If 
' End logging
oFile.WriteLine "  => Completed at " & Date & " " & Time
WScript.Echo "Script Completed"
WScript.Quit (oFile.Close)
Sub DeleteSubkeys(sTempHiveKeyPath)
 Dim aSubKeys, oSubKey
    oReg.EnumKey HKLM, sTempHiveKeyPath, aSubKeys
    If IsArray(aSubKeys) Then
        For Each oSubKey In aSubKeys
            DeleteSubkeys sTempHiveKeyPath & "\" & oSubKey
    End If
    oReg.DeleteKey HKLM, sTempHiveKeyPath
End Sub


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s