Creates a key or value in the registry.
RegWrite "keyname" [,"valuename", "type", value]
Parameters
keyname | The registry key to write to. If no other parameters are specified this key will simply be created. |
valuename | The valuename to write to. |
type | Type of key to write: "REG_SZ", "REG_MULTI_SZ", "REG_EXPAND_SZ", "REG_DWORD", or "REG_BINARY". |
value | The value to write. |
Return Value
Success: | Returns 1. |
Failure: | Returns 0 if error writing registry key or value. |
Remarks
A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").
Related
RegDelete, RegRead
Example
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
' Write a single REG_SZ value
oAutoIt.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_SZ", "Hello this is a test"
' Write the REG_MULTI_SZ value of "line1" and "line2"
oAutoIt.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_MULTI_SZ", "line1" & @LF & "line2"
' INCORRECT uses of REG_MULTI_SZ
oAutoIt.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_MULTI_SZ", "line1" & @LF & "line2" & @LF
oAutoIt.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_MULTI_SZ", "line1" & @LF & @LF & "line2" & @LF