Skip to content

$cs.Reg_SetDword

Writes a 32-bit REG_DWORD registry value. The key is created automatically if it doesn’t exist yet. Throws an error if the value can’t be written, for example because access is denied.

$cs.Reg_SetDword(string registryroot, string regkey, string regvaluename, int regvaluedata)

Root hive: HKLM/HKEY_LOCAL_MACHINE, HKCU/HKEY_CURRENT_USER, or HKU/HKEY_USERS. PowerPacks run as SYSTEM, so HKCU is the SYSTEM account’s hive, not the logged-on user’s. To change user settings, see Invoke-RunAsLoggedOnUser.

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

Name of the value to write.

Signed 32-bit integer to write, from -2147483648 to 2147483647. To write a DWORD above 0x7FFFFFFF, pass the matching negative number — for example, -1 writes 0xFFFFFFFF.

None.

Terminal window
$cs.Reg_SetDword('HKLM', 'Software\Adobe\Acrobat Reader\DC\AVGeneral', 'bisFirstLaunch', 0)

Writing a feature-flag DWORD during PostInstall so the application enables an optional module on next launch.

Terminal window
$cs.Reg_SetDword('HKLM', 'SOFTWARE\Contoso\AppSuite\Features\Reporting', 'Enabled', 1)
$cs.Job_WriteLog("Enabled the Reporting feature")

Writing a build number as an integer marker so future installs can detect what’s already on the machine.

Terminal window
$cs.Reg_SetDword('HKLM', 'SOFTWARE\Contoso\AppSuite', 'BuildNumber', 4712)

$cs.Reg_SetInteger $cs.Reg_SetQword $cs.Reg_GetInteger