Command Reference

Read from Registry

Reads a value from the Registry and assigns it to a variable.

Action ID: 12
Action Category: Registry

Settings

Variable name

The name of the variable to store the result in.

Default value

The default value to assign to the variable if the Registry key does not exist or cannot be read.

Main key

The main or "root" key where the sub key can be found.

Sub key

The sub key to read from.

Value name

The name of the Registry value (in the sub key) to read from.

Set variable to"TRUE" if key exists

When this is checked, the variable will be set to "TRUE" if the key exists or to the Default value if the key doesn't exist.

Auto-expand if value of type REG_EXPAND_SZ

If the value turns out to be of type REG_EXPAND_SZ and this is checked, the value will be expanded before it is stored in the variable.

Return Values

Value
(%LastErrorNum%)

Simple Message
(%LastErrorMsg%)

Verbose Message
(%LastErrorDetails%)

0 (OK)

 

 

1

Could not read from the Registry.

Could not open key.
<<Main key\Sub key\Value name>>

2

Could not read from the Registry.

Could not read value.
<<Main key\Sub key\Value name>>

Example

In this example, we will read the location of our previous installation from the registry and store it in a custom variable named %PreviousLocation%.

Variable name: %PreviousLocation%
Default value: Not Installed
Main key: HKEY_CURRENT_USER
Sub key: Software\My Company\The Product
Value name: InstallDir
Set variable to TRUE if Sub Key exists: Unchecked
Auto-expand if value is of type REG_EXPAND_SZ: Unchecked

 

See Also: Alphabetical List of Actions, Categorical List of Actions, On Error tab