WshShell.RegWrite

The RegWrite method sets the registry key or value named by strName.

Syntax

WshShell.RegWrite strName, anyValue, [strType]
 

Parameters

strName
If strName ends with a backslash character (\), this method sets the key instead of the value.

The strName parameter must begin with one of following root key names.
Short Long
HKCU HKEY_CURRENT_USER
HKLM HKEY_LOCAL_MACHINE
HKCR HKEY_CLASSES_ROOT
HKEY_USERS
HKEY_CURRENT_CONFIG

anyValue
The RegWrite method automatically converts anyValue to a string when strType is REG_SZ or REG_EXPAND_SZ. If strType is REG_DWORD, anyValue is converted to an integer. If strType is REG_BINARY, anyValue must be an integer.
strType
The RegWrite method supports strType as REG_SZ, REG_EXPAND_SZ, REG_DWORD and REG_BINARY. If another data type is passed as strType, RegWrite returns E_INVALIDARG.

Example

Set WshShell = Wscript.CreateObject("Wscript.Shell")

WshShell.RegWrite "HKCU\ScriptEngine\Value", "Some string value"
WshShell.RegWrite "HKCU\ScriptEngine\Key\", 1 "REG_DWORD"
 

See Also

WshShell.RegDelete method, WshShell.RegWrite method