Microsoft® Windows® Script Host RegWrite Method |
WSH Reference Version 1 |
Sets the registry key or value named by strName.
object.RegWrite strName, anyValue [,strType]
Part Description object WshShell object. strName Key or value name to write. anyValue The value to write into the key or registry value. strType Optional. The data type for the value being stored in the registry.
If strName ends with the backslash character (\), this method returns the key instead of the value. StrName 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 RegWrite 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.
RegWrite 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.
The following example writes a value and key entry into the registry:Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.RegWrite "HKCU\ScriptEngine\Value", "Some string value" WshShell.RegWrite "HKCU\ScriptEngine\Key\", 1 ,"REG_DWORD"