In tip 9615, we recovered data from a corrupted Windows XP user profile.
To recover some of the registry entries from the old profile, assuming it is not too corrupted, I have scripted ExportOldHKCU.bat.
The syntax for using ExportOldHKCU.bat is:
ExportOldHKCU Path2NTUser.dat
Where Path2NTUser.dat is the path to the old profile's NTUser.dat file, like "C:\Documents and Settings\Jerry\NTUser.dat".
A <CurrentUserName>_HKCU.REG file is created in the current folder. You can remove any registry entries you don't want to migrate from this file, and then run REGEDIT /S <CurrentUserName>_HKCU.REG.
ExportOldHKCU.bat contains:
@echo off if \{%1\}==\{\} @echo Syntax: ExportOldHKCU Path2NTUser.dat&goto :EOF if not exist %1 Syntax: ExportOldHKCU Path2NTUser.dat - %1 NOT found.&goto :EOF setlocal set file=%1 if exist "%TEMP%\ExportOldHKCU.TMP" del /q "%TEMP%\ExportOldHKCU.TMP" REG LOAD HKU\ZZZ %file% REGEDIT /a "%TEMP%\ExportOldHKCU.TMP" "HKEY_USERS\ZZZ" REG UNLOAD HKU\ZZZ @echo dim fso, readfile, contents, writefile, work>"%TEMP%\ExportOldHKCU.VBS" @echo dim objArguments, FullFileName, NewFilename>>"%TEMP%\ExportOldHKCU.VBS" @echo Set objArguments = Wscript.Arguments>>"%TEMP%\ExportOldHKCU.VBS" @echo set fso = CreateObject("Scripting.FileSystemObject")>>"%TEMP%\ExportOldHKCU.VBS" @echo FullFileName=objArguments(0)>>"%TEMP%\ExportOldHKCU.VBS" @echo NewFilename=objArguments(1)>>"%TEMP%\ExportOldHKCU.VBS" @echo set readfile = fso.OpenTextFile(FullFileName, 1, false)>>"%TEMP%\ExportOldHKCU.VBS" @echo set writefile = fso.CreateTextFile(NewFileName, 2)>>"%TEMP%\ExportOldHKCU.VBS" @echo Do until readfile.AtEndOfStream = True>>"%TEMP%\ExportOldHKCU.VBS" @echo. contents = readfile.ReadLine>>"%TEMP%\ExportOldHKCU.VBS" @echo. work = Replace(contents, "HKEY_USERS\ZZZ", "HKEY_CURRENT_USER")>>"%TEMP%\ExportOldHKCU.VBS" @echo. writefile.writeLine work>>"%TEMP%\ExportOldHKCU.VBS" @echo loop>>"%TEMP%\ExportOldHKCU.VBS" @echo readfile.close>>"%TEMP%\ExportOldHKCU.VBS" @echo writefile.close>>"%TEMP%\ExportOldHKCU.VBS" cscript //nologo "%TEMP%\ExportOldHKCU.VBS" "%TEMP%\ExportOldHKCU.TMP" "%UserName%_HKCU.REG" del /q "%TEMP%\ExportOldHKCU.VBS" del /q "%TEMP%\ExportOldHKCU.TMP" endlocal
0 comments
Hide comments