# Reg_LoadHive

> Loads an off-line registry hive into a temp hive in the current registry, so the normal registry functions can manipulate it.

Source: https://docs.capaone.com/capainstaller/vb-scripting-library/osd-scripting-library/registry-functions-osd/reg-loadhive/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

[VB Scripting Library](/capainstaller/vb-scripting-library/) > [OSD Scripting Library](/capainstaller/vb-scripting-library/osd-scripting-library/) > [Registry Functions (OSD)](/capainstaller/vb-scripting-library/osd-scripting-library/registry-functions-osd/)

### Reg_LoadHive(sTempHive,sFile)

Loads an off-line hive into a temp hive in the current registry, so it can be manipulated using the normal registry functions found in the CapaInstaller Scripting Library.

### Arguments

| ARGUMENT   | DESCRIPTION                                                             | TYPE   |
|:-----------|:------------------------------------------------------------------------|:-------|
| sTempHive  | The temporary hive name that will hold the reference to the loaded hive | String |
| sFile      | The full path to the hive file that is to be loaded                     | String |

### Return Type

Boolean, TRUE if function completed successfully.

### Remarks

:::caution
It is important to unload the hive again after making changes, otherwise it can become corrupted.
:::

### Example

The following example will load the HKLM\Software hive from the old operating system to HKLM\TempHive, and the attempt to read the old computer name.

**VBScript**

```vb
Private Function IncludeScript(sScriptFile)
 '...
End Function

'Begin
  bStatus=True
  If bStatus Then bStatus=IncludeScript("customlib.cis")
  If bStatus Then bStatus=IncludeLibrary("Capalib.cin")
  If bStatus Then bStatus=IncludeLibrary("Osdlib.cin")
  If bStatus Then bStatus=Job_Start("WS","Script Name","1.0","ScriptName.log","INSTALL")
  If bStatus Then bStatus=OSD_Initialize()

  If bStatus Then bStatus=Reg_LoadHive("HKLM\TempHive","C:\Windows\System32\config\software")
  If bStatus Then bStatus=Reg_GetString("HKLM","TempHive\CapaSystems\CapaInstaller\Client","ComputerName",False)
  If bStatus and gsValue <> "" Then 
    bStatus=Dialog_ShowInformation("The old computer name is: " & gsValue)
  Else
    bStatus=Dialog_ShowInformation("The old computer name could not be found")
  End If
  If bStatus Then bStatus=Reg_UnLoadHive("HKLM\TempHive")

  Job_End(bStatus)
'End main

```

### See Also

[Scripting Guidelines](/capainstaller/vb-scripting-library/scripting-guidelines/), [Reg_UnloadHive](/capainstaller/vb-scripting-library/osd-scripting-library/registry-functions-osd/reg-unloadhive/), [Dialog_ShowInformation](/capainstaller/vb-scripting-library/osd-scripting-library/dialog-functions-osd/dialog-showinformation/) [Constants](/capainstaller/vb-scripting-library/addendum/constants/) [Package Property](/capainstaller/vb-scripting-library/addendum/package-property/) [Variables](/capainstaller/vb-scripting-library/addendum/variables/)
