$cs.Reg_SetDword
Description
Section titled “Description”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.
Syntax
Section titled “Syntax”$cs.Reg_SetDword(string registryroot, string regkey, string regvaluename, int regvaluedata)
Parameters
Section titled “Parameters”registryroot (String)
Section titled “registryroot (String)”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.
regkey (String)
Section titled “regkey (String)”Registry key path, relative to registryroot. Created automatically if it doesn’t exist.
regvaluename (String)
Section titled “regvaluename (String)”Name of the value to write.
regvaluedata (Integer)
Section titled “regvaluedata (Integer)”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.
Return value
Section titled “Return value”None.
Example
Section titled “Example”$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.
$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.
$cs.Reg_SetDword('HKLM', 'SOFTWARE\Contoso\AppSuite', 'BuildNumber', 4712)