REGRESTOREKEY
5/10/2007
This command reads the registry information in a specified file and copies it over the specified key. This registry information may be in the form of a key and multiple levels of subkeys.
Syntax
14, [ErrorMode], hKey, [ExpandMode], Key, [ExpandMode],
FileName, Flags
Parameters
ErrorMode
Optional. Specified as a decimal representation of a hexadecimal bitmask. Values must be specified in decimal format. The following table shows the possible values.Value Name Description 0 (0xnnnn0000)
DAERH_ABORT
Default. The abort-on-error mode stops the command file from processing further.
32768 (0xnnnn8000)
DAERH_IGNORE
The ignore-on-error mode continues by processing the next command when an error occurs.
32769-33023 (0x000080xx where xx!=00 is the number of retries)
DAERH_RETRY_WITHIGNORE
The retry-on-error with ignore mode retries the offending command up to 255 times. If the number of retries exceeds the retry count, this mode continues processing the next command.
1-255(0x00xx where xx!=0 is the number of retries from 1-255)
DAERH_RETRY_WITHABORT
The retry-on-error with abort mode retries the offending command up to 255 times. If the number of retries exceeds the retry count, the command file processing halts.
65536 – 4294901760(0xFFFFnnnn where FFFF is the delay mask in seconds)
DAERH_DELAYMASK
The delay error mode value is added to either the DAERH_RETRY_WITHIGNORE or the DAERH_RETRY_WITHABORT value to cause a delay between retries. This value is in seconds and has a range between 1 and 65535.
Note
Parsing errors, especially the passing of not valid command parameters, generates an error in DAERH_ABORT error mode. With logging enabled, an appropriate error message is output to the log file.
hKey
Predefined registry handles. The following table shows the values for this parameter.Value Name 2147483648
HKEY_CLASSES_ROOT
2147483649
HKEY_CURRENT_USER
2147483650
HKEY_LOCAL_MACHINE
2147483651
HKEY_USERS
2147483652
HKEY_PERFORMANCE_DATA
2147483653
HKEY_CURRENT_CONFIG
ExpandMode
Optional. Specifies if the string that follows it is an environment variable that should be expanded. Can occur multiple times with this command. The following table shows the possible values.Value Description 0
Does not expand the string.
1
Device Update Agent expands the string on the embedded device.
2
Device Update Agent script compiler expands the string on the developer computer.
- Key
String specifying the name of a key that this function opens or creates. This key must be a subkey of the key identified by the Key parameter.
- FileName
String containing the name of the file with registry information. This file is typically created by using the RegSaveKey function.
Flags
The following table shows the possible values for this parameter.Value Name Description 1
DAREG_WHOLE_HIVE_VOLATILE
If specified, a new, volatile memory that is the only collection of registry information — a hive — is created. If REG_WHOLE_HIVE_VOLATILE is specified, the key identified by the hKey parameter must be either the HKEY_USERS or HKEY_LOCAL_MACHINE value.
2
DAREG_REFRESH_HIVE
If specified, the location of the hive the hKey parameter points to is restored immediately following the last flush. The hive must not call RegRestoreKey with DAREG_NO_LAZY_FLUSH specified as the value of this parameter, the caller must have TCB privilege, and the handle to which the hKey parameter refers must point to the root of the hive.
4
DAREG_NO_LAZY_FLUSH
If specified, the key or hive specified by the hKey parameter is flushed automatically after a regular an interval of time.
8
DAREG_FORCE_RESTORE
If specified, the restore operation is executed even if open handles exist at or beneath the location in the registry hierarchy to which the hKey parameter points.
Remarks
For more information, see the Microsoft Windows SDK documentation at this Microsoft Web site.
Example
The following example shows typical use.
//
// RegRestoreKey
//
REGRESTOREKEY,,HKEY_LOCAL_MACHINE,,SYSTEM\CurrentControlSet\SampleKey,,c:\dua_temp\SampleKey.reg,DAREG_FORCE_RESTORE