# $cs.Reg_SetString

> Writes a REG_SZ (string) registry value. The key is created automatically if it doesn't exist yet.

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

### Description

Writes a `REG_SZ` (string) registry value. The key is created automatically if it doesn't exist yet.

### Syntax

$cs.Reg_SetString(string registryroot, string regkey, string regvaluename, string regvaluedata)

### Parameters

#### registryroot (String)

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

#### regkey (String)

Registry key path, relative to `registryroot`. Created automatically if it doesn't exist.

#### regvaluename (String)

Name of the value to write.

#### regvaluedata (String)

String to write.

### Return value

None.

### Example

**PowerShell**

```powershell
$cs.Reg_SetString('HKLM', 'SOFTWARE\Contoso\AppSuite', 'InstallPath', $global:Packageroot)
```

Writing a couple of related configuration values under the application's own settings key:

```powershell
$cs.Reg_SetString('HKLM', 'SOFTWARE\Contoso\AppSuite', 'ConfigServer', 'https://config.contoso.example')
$cs.Reg_SetString('HKLM', 'SOFTWARE\Contoso\AppSuite', 'Environment', 'Production')
```

Writing a custom app-tracking marker so PowerPacks can later confirm this exact package version was applied.

```powershell
$cs.Reg_SetString('HKLM', 'SOFTWARE\Contoso\AppSuite', 'InstalledByPackage', 'AppSuite-4.8.1')
$cs.Job_WriteLog("Recorded package tracking marker")
```

### Related functions

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