# determine the framework guid. this will be unique for each install $productskey = "HKLM:\SOFTWARE\Classes\Installer\Products" $installedproducts = get-childitem $productskey foreach ($product in $installedproducts) { $product = $product -replace("HKEY_LOCAL_MACHINE","HKLM:") $prodname = get-itemproperty -path $product -name "ProductName" if ($prodname -match "Microsoft .NET Framework 3.5") { $frameworkguid = $prodname.PSChildName } } # get a list of the registry keys to parse $regkeys = reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18 /s # find and replace all instances of D?\ with C?\ for ($i = 0; $i -lt $regkeys.Length; $i++) { if ($regkeys[$i] -match "D\?\\") { $badkey = $regkeys[$i-1] $badkey = $badkey -replace("HKEY_LOCAL_MACHINE","HKLM:") $badvalue = get-itemproperty -path $badkey -name $frameworkguid $goodvalue = $badvalue.$frameworkguid -replace ("D\?\\", "C?\") write-host "updating " $badkey "\$frameworkguidto " $goodvalue set-itemproperty -path $badkey -name $frameworkguid -value $goodvalue } } if(!(test-path "C:\Windows\Microsoft.NET\Framework\v3.5\WFServicesReg.exe")) { write-host -fore 'Red' -back 'Black' "Please copy WFServicesReg.exe from a working installation to C:\Windows\Microsoft.NET\Framework\v3.5 " } if(!(test-path "C:\Windows\Microsoft.NET\Framework64\v3.5\WFServicesReg.exe")) { write-host -fore 'Red' -back 'Black' "Please copy WFServicesReg.exe from a working installation to C:\Windows\Microsoft.NET\Framework64\v3.5" }