ProblemYou want to export part of the Registry to a Registry (.reg) file. SolutionUsing a graphical user interface
Using a command-line interfaceThe following command exports part of the Registry to a file: > regedit /e <FilePath> <RegKey> For example: > regedit /e c:\rallencorp.reg HKEY_LOCAL_MACHINE\Software\Rallencorp Using VBScript' This code exports the contents of a key to a Registry file. ' Since there are no scripting functions to do this, I simply ' shell out to the regedit tool to do it. ' strCommand = "regedit /e <FilePath> <RegKey>" strCommand = "regedit /e c:\rallencorp.reg HKEY_LOCAL_MACHINE\Software\Rallencorp" set objWshShell = WScript.CreateObject("WScript.Shell") intRC = objWshShell.Run(strCommand, 0, TRUE) if intRC <> 0 then WScript.Echo "Error returned from exporting Registry: " & intRC else WScript.Echo "No errors returned from exporting the Registry file" end if DiscussionThe Registry Editor allows you to export parts of the Registry to a text-based file. You can then modify the file and import it back into the Registry (perhaps on another host) using Registry Editor (see Recipe 9.5). These Registry files have an extension of .reg. Windows recognizes this extension so that if you double-click on a .reg file, you will automatically be prompted to import its contents into the Registry. The format for this file is pretty easy to follow. Here is an example Registry file containing the contents of the HKLM\Software\Google key: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\Software\Google] "DesktopBarAdminInstall"=dword:00000001 [HKEY_LOCAL_MACHINE\Software\Google\CustomSearch] [HKEY_LOCAL_MACHINE\Software\Google\Deskbar] "path"="C:\\PROGRA~1\\Google\\GGTASK~1.DLL" "Version"=dword:00000051 [HKEY_LOCAL_MACHINE\Software\Google\Miniviewer] "path"="C:\\Program Files\\Google\\ggviewer81-47.exe" "Version"=dword:00000051 [HKEY_LOCAL_MACHINE\Software\Google\NavClient] "test"="41" "brand"="GGLD" "installtime"="1068347808" "sent"=dword:00000001 [HKEY_LOCAL_MACHINE\Software\Google\NavClient\Obsolete] [HKEY_LOCAL_MACHINE\Software\Google\Verscheck] "path"="C:\\Program Files\\Google\\ggverscheck81-47.exe" "Version"=dword:00000051 Exporting the Registry is useful if you need to implement a significant change to a system. A Registry export can act both as a backup in case things go wrong and as a change log to help you determine what was modified after the change. |