$cs.Reg_DelTree
Description
Section titled “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
Section titled “Syntax”$cs.Reg_DelTree(string regroot, string regpath, string regkey)
Parameters
Section titled “Parameters”regroot (String)
Section titled “regroot (String)”Root hive: HKLM/HKEY_LOCAL_MACHINE, HKCU/HKEY_CURRENT_USER, or HKU/HKEY_USERS.
regpath (String)
Section titled “regpath (String)”Registry key path to delete, relative to regroot.
regkey (String)
Section titled “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
Section titled “Return value”None.
Example
Section titled “Example”$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.
$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.
$cs.Reg_DelTree('HKLM', 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{AC76BA86-7AD7-1033-7B44-AC0F074E4100}')