Skip to content

$cs.Reg_GetMultiString

Reads a REG_MULTI_SZ (multi-string) registry value. Returns an empty array if the value isn’t found — never $null.

$cs.Reg_GetMultiString(string registryroot, string regkey, string regvalue)

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

Registry key path containing the value, relative to registryroot.

Name of the value to retrieve. Pass "" for the key’s default value.

String array (string[]). Empty array if the value isn’t found.

Terminal window
$dependencies = $cs.Reg_GetMultiString('HKLM', 'SYSTEM\CurrentControlSet\Services\W3SVC', 'DependOnService')
foreach ($dependency in $dependencies) {
$cs.Job_WriteLog("W3SVC depends on service: $dependency")
}

Reading a list of installed components written by a previous install so the uninstaller knows which per-component keys to remove.

Terminal window
$installedComponents = $cs.Reg_GetMultiString('HKLM', 'SOFTWARE\Contoso\AppSuite', 'InstalledComponents')
if ($installedComponents.Length -eq 0)
{
$cs.Job_WriteLog("No component list found, nothing to uninstall")
}
foreach ($component in $installedComponents) {
$cs.Job_WriteLog("Removing component: $component")
$cs.Reg_DelTree('HKLM', "SOFTWARE\Contoso\AppSuite\Components\$component")
}

Checking whether a specific dependency was recorded in a multi-string list of prerequisites before continuing.

Terminal window
$prereqs = $cs.Reg_GetMultiString('HKLM', 'SOFTWARE\Contoso\AppSuite', 'Prerequisites')
if ($prereqs -contains 'VCRedist2015-2022-x64')
{
$cs.Job_WriteLog("Required VC++ Redistributable is already recorded as installed")
}

$cs.Reg_GetString $cs.Reg_GetInteger