# $cs.Reg_ExistVariable

> Checks whether a named value exists under a registry key. Returns $false (not an exception) if either the key or the value is missing.

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

### Description

Checks whether a named value exists under a registry key. Returns `$false` (not an exception) if either the key or the value is missing.

### Syntax

$cs.Reg_ExistVariable(string registryroot, string regkey, string regvariable)

### Parameters

#### registryroot (String)

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

#### regkey (String)

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

#### regvariable (String)

Name of the value to check for.

### Return value

Boolean — `$true` if the value exists, otherwise `$false`.

### Example

**PowerShell**

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

Checking that a specific setting exists before reading it with `Reg_GetString`, to distinguish "not configured" from "configured as empty string".

```powershell
if ($cs.Reg_ExistVariable('HKLM', 'SOFTWARE\Contoso\AppSuite', 'InstallPath'))
{
    $installPath = $cs.Reg_GetString('HKLM', 'SOFTWARE\Contoso\AppSuite', 'InstallPath')
    $cs.Job_WriteLog("AppSuite installed at: $installPath")
}
else
{
    $cs.Job_WriteLog("InstallPath setting not found")
}
```

Verifying a licensing value is present before proceeding with a license-dependent install step.

```powershell
if (-not $cs.Reg_ExistVariable('HKLM', 'SOFTWARE\Contoso\AppSuite\Licensing', 'LicenseKey'))
{
    Exit-PSScript -exitcode 1 -exitmessage "No license key configured, aborting install"
}
```

### Related functions

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