Skip to content

$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.

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

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

Registry key path to delete, relative to regroot.

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.

None.

Terminal window
$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.

Terminal window
$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.

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

$cs.Reg_ExistKey $cs.Reg_CreateKey $cs.Reg_DeleteVariable