9.4. Exporting Registry Files
You want to export part of the registry to a registry (.reg) file.
Using a graphical user interface
Open the Registry Editor (regedit.exe).
In the left pane, browse to the key you want to export.
Right-click on the key and select Export.
Enter a file name to save the export to and click Save.
Using a command-line interface
The following command exports part of the registry to a file:
> regedit /e
> regedit /e c:\rallencorp.reg HKEY_LOCAL_MACHINE\Software\Rallencorp
' 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
<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
The 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 ...