# $cs.Reg_CreateKey

> Creates a registry key at the given path, automatically creating any missing parent keys along the way.

Source: https://docs.capaone.com/capainstaller/powerpacks/cs-reg-createkey/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Creates a registry key at the given path, automatically creating any missing parent keys along the way. If the key already exists, nothing happens.

### Syntax

$cs.Reg_CreateKey(string regroot, string regpath)

### Parameters

#### regroot (String)

Root hive: `HKLM`/`HKEY_LOCAL_MACHINE`, `HKCU`/`HKEY_CURRENT_USER`, or `HKU`/`HKEY_USERS`.

#### regpath (String)

Registry key path to create, relative to `regroot`. Missing parent keys are created automatically.

### Return value

None.

### Example

**PowerShell**

```powershell
$cs.Reg_CreateKey('HKLM', 'SOFTWARE\7-Zip')
```

Creating a nested vendor/product key structure to hold app-specific configuration, even though none of the parent keys exist yet.

```powershell
$cs.Reg_CreateKey('HKLM', 'SOFTWARE\Contoso\AppSuite\Licensing')
$cs.Job_WriteLog("Created Licensing configuration key")
```

Creating a per-feature subkey during `PostInstall` so later steps can write feature-specific settings into it.

```powershell
$cs.Reg_CreateKey('HKLM', 'SOFTWARE\Contoso\AppSuite\Features\Reporting')
$cs.Reg_SetDword('HKLM', 'SOFTWARE\Contoso\AppSuite\Features\Reporting', 'Enabled', 1)
```

### Related functions

[$cs.Reg_ExistKey](/capainstaller/powerpacks/cs-reg-existkey/) [$cs.Reg_DelTree](/capainstaller/powerpacks/cs-reg-deltree/) [$cs.Reg_SetString](/capainstaller/powerpacks/cs-reg-setstring/)
