# $cs.Reg_DeleteVariable

> Deletes a single named value from a registry key, leaving the key itself in place. Pass an empty string "" as regvalue to delete the key's unnamed default value.

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

### Description

Deletes a single named value from a registry key, leaving the key itself in place. Pass an empty string `""` as `regvalue` to delete the key's unnamed default value.

### Syntax

$cs.Reg_DeleteVariable(string regroot, string regpath, string regvalue)

### Parameters

#### regroot (String)

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

#### regpath (String)

Registry key path containing the value, relative to `regroot`.

#### regvalue (String)

Name of the value to delete. Pass `""` to delete the key's default (unnamed) value.

### Return value

None.

### Example

**PowerShell**

```powershell
if ($cs.Reg_ExistVariable('HKLM', 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'Everything'))
{
    $cs.Reg_DeleteVariable('HKLM', 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'Everything')
}
```

Removing a single stale setting value during `PostInstall` cleanup, without touching the rest of the key.

```powershell
$cs.Reg_DeleteVariable('HKLM', 'SOFTWARE\Contoso\AppSuite', 'LegacyLicenseServer')
$cs.Job_WriteLog("Removed obsolete LegacyLicenseServer setting")
```

Deleting a key's default (unnamed) value by passing `""` as `regvalue`, leaving all other named values in place.

```powershell
$cs.Reg_DeleteVariable('HKLM', 'SOFTWARE\Classes\.contoso', '')
```

### Related functions

[$cs.Reg_ExistVariable](/capainstaller/powerpacks/cs-reg-existvariable/) [$cs.Reg_GetString](/capainstaller/powerpacks/cs-reg-getstring/) [$cs.Reg_DelTree](/capainstaller/powerpacks/cs-reg-deltree/)
