Frank said:
i want to use the Munge Tool from NT4 Ressource Kit to replace any strings in a reg-File.
But it doesen`t work on XP.
My main problem is to migrate ODBC Drivers from NT4 to XP and my solution is to export the Registry Keys,
change the Directory Path and Import it to XP.
Any suggestions would be greatly appreciated.
Hi
A vbscript solution that exports the key in sKey to a temporary
registry file using regedit.exe, replaces text defined in sFrom to
the the text defined in sTo, and then imports the file into registry:
'--------------------8<----------------------
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Const OverwriteIfExist = -1
' change the data in the tree following values to what fits you
sKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Software1"
sFrom = "F:\"
sTo = "G:\"
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
' create a temporary registry file name
sRegTmpFile = oFSO.GetSpecialFolder(2).ShortPath & "\" & oFSO.GetTempName
' export the registry key with content to a file
sCmd = "regedit.exe /S /E:A """ & sRegTmpFile & """ " & """" & sKey & """"
oShell.Run sCmd, 0, True
' open and read the registry file
Set fFile = oFSO.OpenTextFile(sRegTmpFile, ForReading, _
FailIfNotExist, OpenAsASCII)
sContent = fFile.ReadAll
fFile.Close
' replace the text (not case sensitive)
sContent = Replace(sContent, sFrom, sTo, 1, -1, vbTextCompare)
' create an updated reg file
Set fFile = oFSO.CreateTextFile(sRegTmpFile, OverwriteIfExist, OpenAsASCII)
fFile.WriteLine sContent
fFile.Close
' import the registry file
oShell.Run "regedit.exe /S """ & sRegTmpFile & """", 1, True
' delete the file
oFSO.DeleteFile sRegTmpFile
'--------------------8<----------------------
WSH 5.6 documentation (local help file) can be downloaded from here if you
haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp