9.5. Importing Registry Files
You want to import changes to the registry using a registry (.reg) file.
Using a graphical user interface
Open an Explorer (explorer.exe) window.
Browse to the .reg file you want to import.
Double-click on the file.
Click Yes to confirm the import.
You can accomplish the same thing within Registry Editor by going to File → Import.
Using a command-line interface
The following command imports a registry key or subkey:
> regedit /s
> regedit /s c:\rallencorp.reg
' This code imports the contents of 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 /s
<FilePath>" strCommand = "regedit /s c:\rallencorp.reg" set objWshShell = WScript.CreateObject("WScript.Shell") intRC = objWshShell.Run(strCommand, 0, TRUE) if intRC <> 0 then WScript.Echo "Error returned from importing registry: " & intRC else WScript.Echo "No errors returned from importing the registry file" end if
Importing a registry file is as easy as double-clicking it, but this is where the danger lies. Be careful anytime you import a registry file; make sure it contains exactly what you want to import. If you accidentally import the wrong file, it can unintentionally overwrite values. Since registry files are text based, open a file in a text editor such as Notepad to see what it contains.