# $cs.Reg_DelTree

> Recursively deletes a registry key and everything under it (subkeys and values). If the key doesn't exist, the function returns silently without an error.

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

### Description

Recursively deletes a registry key and everything under it (subkeys and values). If the key doesn't exist, the function returns silently without an error.

### Syntax

$cs.Reg_DelTree(string regroot, string regpath, string regkey)

### Parameters

#### regroot (String)

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

#### regpath (String)

Registry key path to delete, relative to `regroot`.

#### regkey (String)

Optional, kept only for backward compatibility. If supplied, it is appended onto `regpath` as an extra path segment before deletion. For new code, pass the complete key path in `regpath` and omit this parameter.

### Return value

None.

### Example

**PowerShell**

```powershell
$cs.Reg_DelTree('HKLM', 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Teamviewer QuickSupport')
```

> An equivalent two-parameter alias `$cs.Reg_DeleteTree(regroot, regpath)` also exists and behaves identically.

Removing an entire vendor key tree during `Uninstall`, including every version and feature subkey underneath it.

```powershell
$cs.Reg_DelTree('HKLM', 'SOFTWARE\Contoso\AppSuite')
$cs.Job_WriteLog("Removed all AppSuite configuration from the registry")
```

Cleaning up a leftover uninstall-registry entry left behind by an older installer that didn't register itself properly. Since `Reg_DelTree` is silent if the key doesn't exist, no existence check is needed first.

```powershell
$cs.Reg_DelTree('HKLM', 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-7AD7-1033-7B44-AC0F074E4100}')
```

### Related functions

[$cs.Reg_ExistKey](/capainstaller/powerpacks/cs-reg-existkey/) [$cs.Reg_CreateKey](/capainstaller/powerpacks/cs-reg-createkey/) [$cs.Reg_DeleteVariable](/capainstaller/powerpacks/cs-reg-deletevariable/)
