Previous Topic: regSetKeyValues--Set Registry Key Values From an Array (Function)Next Topic: setProcExitCode--Set AutoShell Exit Code (Function)


regSetVal--Set Registry Value (Function)

The regSetVal creates or sets a value for the registry key specified by sKey on the local system or a remote system. If the value identified by sValName does not exist, it is created, otherwise the existing setting is overwritten with the value.

The function has the following syntax:

regSetVal(sKey, sValName, value, [type])
sKey

Specifies the registry key.

sValName

Specifies the name of the value.

value

Defines the value.

type

Specifies the type of the value.

If the function fails, it raises an exception. Otherwise it returns true.

Examples

Set REG_DWORD value for key HKLM\Software\ACME named "Number" to 42:

regSetVal("HKLM\\Software\\ACME", "Number", 42);

Set REG_SZ value for key HKLM\Software\ACME named "Label" to "Hello" with error handling:

try {
    regSetVal("HKLM\\Software\\ACME", "Label", "Hello");
    ? "Success"
}
catch(e) {
    ? "Failure:", e
}

Set a REG_EXPAND_SZ value:

regSetVal("HKLM\\Software\\ACME", "MyPath", "%Path%;c:\\MyDir", REG_EXPAND_SZ);

Set a REG_MULTI_SZ value:

arr=["Alice", "Bob", "Carol"];
    regSetVal("HKLM\\Software\\ACME", "People", arr);

Set string value on remote machine client8:

regSetVal("client8::HKLM\\Software\\ACME", "Name", "Bob");

See also:

regCreateKey--Create a Registry Key (Function)

regDeleteVal--Delete a Registry Value (Function)

regGetVal--Get Registry Value (Function)

regSetKeyValues--Set Registry Key Values From an Array (Function)