Windows Registry
View on Wikipedia
| Windows Registry Editor | |
|---|---|
Registry Editor, the user interface for the registry, in Windows 11 | |
| Other names | regedit |
| Developer | Microsoft |
| Initial release | April 6, 1992 with Windows 3.1 |
| Operating system | Microsoft Windows |
| Platform | IA-32, x86-64 and ARM (and historically DEC Alpha, Itanium, MIPS, and PowerPC) |
| Included with | Microsoft Windows |
| Type | Hierarchical database |
| License | Proprietary |
| Website | learn |
The Windows Registry is a hierarchical database that stores low-level settings for the Microsoft Windows operating system and for applications that opt to use the registry. The kernel, device drivers, services, Security Accounts Manager, and user interfaces can all use the registry. The registry also allows access to counters for profiling system performance.
In other words, the registry or Windows Registry contains information, settings, options, and other values for programs and hardware installed on all versions of Microsoft Windows operating systems. For example, when a program is installed, a new subkey containing settings such as a program's location, its version, and how to start the program, are all added to the Windows Registry.
When introduced with Windows 3.1, the Windows Registry primarily stored configuration information for COM-based components. Windows 95 and Windows NT extended its use to rationalize and centralize the information in the profusion of INI files, which held the configurations for individual programs, and were stored at various locations.[1][2] It is not a requirement for Windows applications to use the Windows Registry. For example, .NET Framework applications use XML files for configuration, while portable applications usually keep their configuration files with their executables.
Rationale
[edit]Prior to the Windows Registry, .INI files stored each program's settings as a text file or binary file, often located in a shared location that did not provide user-specific settings in a multi-user scenario. By contrast, the Windows Registry stores all application settings in one logical repository (but also in a number of discrete files) and in a standardized form. According to Microsoft, this offers several advantages over .INI files.[2][3] Since file parsing is done much more efficiently with a binary format, it may be read from or written to more quickly than a text INI file. Furthermore, strongly typed data can be stored in the registry, as opposed to the text information stored in .INI files. This is a benefit when editing keys manually using regedit.exe, the built-in Windows Registry Editor. Because user-based registry settings are loaded from a user-specific path rather than from a read-only system location, the registry allows multiple users to share the same machine, and also allows programs to work for less privileged users. Backup and restoration is also simplified as the registry can be accessed over a network connection for remote management/support, including from scripts, using the standard set of APIs, as long as the Remote Registry service is running and firewall rules permit this.
Because the registry is a database, it offers improved system integrity with features such as atomic updates. If two processes attempt to update the same registry value at the same time, one process's change will precede the other's and the overall consistency of the data will be maintained. Where changes are made to .INI files, such race conditions can result in inconsistent data that does not match either attempted update. Windows Vista and later operating systems provide transactional updates to the registry by means of the Kernel Transaction Manager, extending the atomicity guarantees across multiple key or value changes with traditional commit–abort semantics. (Note however that NTFS provides such support for the file system as well, so the same guarantees could, in theory, be obtained with traditional configuration files.)
Structure of Registry Key
[edit]Keys and values
[edit]The registry contains two basic elements: keys and values. Registry keys are container objects similar to folders. Registry values are non-container objects similar to files. Keys may contain values and subkeys. Keys are referenced with a syntax similar to Windows' path names, using backslashes to indicate levels of hierarchy. Keys must have a case insensitive name without backslashes.
The hierarchy of registry keys can only be accessed from a known root key handle (which is anonymous but whose effective value is a constant numeric handle) that is mapped to the content of a registry key preloaded by the kernel from a stored "hive", or to the content of a subkey within another root key, or mapped to a registered service or DLL that provides access to its contained subkeys and values.
E.g. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows refers to the subkey "Windows" of the subkey "Microsoft" of the subkey "Software" of the HKEY_LOCAL_MACHINE root key.
There are seven predefined root keys, traditionally named according to their constant handles defined in the Win32 API, or by synonymous abbreviations (depending on applications):[4]
- HKEY_LOCAL_MACHINE or HKLM
- HKEY_CURRENT_CONFIG or HKCC
- HKEY_CLASSES_ROOT or HKCR
- HKEY_CURRENT_USER or HKCU
- HKEY_USERS or HKU
- HKEY_PERFORMANCE_DATA (only in Windows NT, but invisible in the Windows Registry Editor)[5]
- HKEY_DYN_DATA (only in Windows 9x, and visible in the Windows Registry Editor)
Like other files and services in Windows, all registry keys may be restricted by access control lists (ACLs), depending on user privileges, or on security tokens acquired by applications, or on system security policies enforced by the system (these restrictions may be predefined by the system itself, and configured by local system administrators or by domain administrators). Different users, programs, services or remote systems may only see some parts of the hierarchy or distinct hierarchies from the same root keys.
Registry values are name/data pairs stored within keys. Registry values are referenced separately from registry keys. Each registry value stored in a registry key has a unique name whose letter case is not significant. The Windows API functions that query and manipulate registry values take value names separately from the key path or handle that identifies the parent key. Registry values may contain backslashes in their names, but doing so makes them difficult to distinguish from their key paths when using some legacy Windows Registry API functions (whose usage is deprecated in Win32).
The terminology is somewhat misleading, as each registry key is similar to an associative array, where standard terminology would refer to the name part of each registry value as a "key". The terms are a holdout from the 16-bit registry in Windows 3, in which registry keys could not contain arbitrary name/data pairs, but rather contained only one unnamed value (which had to be a string). In this sense, the Windows 3 registry was like a single associative array, in which the keys (in the sense of both 'registry key' and 'associative array key') formed a hierarchy, and the registry values were all strings. When the 32-bit registry was created, so was the additional capability of creating multiple named values per key, and the meanings of the names were somewhat distorted.[6] For compatibility with the previous behavior, each registry key may have a "default" value, whose name is the empty string.
Each value can store arbitrary data with variable length and encoding, but which is associated with a symbolic type (defined as a numeric constant) defining how to parse this data. The standard types are:[7]
| Type ID | Symbolic type name | Meaning and encoding of the data stored in the registry value |
|---|---|---|
| 0 | REG_NONE | No type (the stored value, if any) |
| 1 | REG_SZ | A string value, normally stored and exposed in UTF-16LE (when using the Unicode version of Win32 API functions), usually terminated by a NUL character |
| 2 | REG_EXPAND_SZ | An "expandable" string value that can contain environment variables, normally stored and exposed in UTF-16LE, usually terminated by a NUL character |
| 3 | REG_BINARY | Binary data (any arbitrary data) |
| 4 | REG_DWORD / REG_DWORD_LITTLE_ENDIAN | A DWORD value, a 32-bit unsigned integer (numbers between 0 and 4,294,967,295 [232 – 1]) (little-endian) |
| 5 | REG_DWORD_BIG_ENDIAN | A DWORD value, a 32-bit unsigned integer (numbers between 0 and 4,294,967,295 [232 – 1]) (big-endian) |
| 6 | REG_LINK | A symbolic link (UNICODE) to another registry key, specifying a root key and the path to the target key |
| 7 | REG_MULTI_SZ | A multi-string value, which is an ordered list of non-empty strings, normally stored and exposed in Unicode, each one terminated by a null character, the list being normally terminated by a second null character.[8] |
| 8 | REG_RESOURCE_LIST | A resource list (used by the Plug-n-Play hardware enumeration and configuration) |
| 9 | REG_FULL_RESOURCE_DESCRIPTOR | A resource descriptor (used by the Plug-n-Play hardware enumeration and configuration) |
| 10 | REG_RESOURCE_REQUIREMENTS_LIST | A resource requirements list (used by the Plug-n-Play hardware enumeration and configuration) |
| 11 | REG_QWORD / REG_QWORD_LITTLE_ENDIAN | A QWORD value, a 64-bit integer (either big- or little-endian, or unspecified) (introduced in Windows 2000)[9] |
Root keys
[edit]The keys at the root level of the hierarchical database are generally named by their Windows API definitions, which all begin with "HKEY".[2] They are frequently abbreviated to a three- or four-letter short name starting with "HK" (e.g. HKCU and HKLM). Technically, they are predefined handles (with known constant values) to specific keys that are either maintained in memory, or stored in hive files stored in the local filesystem and loaded by the system kernel at boot time and then shared (with various access rights) between all processes running on the local system, or loaded and mapped in all processes started in a user session when the user logs on the system.
The HKEY_LOCAL_MACHINE (local machine-specific configuration data) and HKEY_CURRENT_USER (user-specific configuration data) nodes have a similar structure to each other; user applications typically look up their settings by first checking for them in HKEY_CURRENT_USER\Software\Vendor's name\Application's name\Version\Setting name, and if the setting is not found, look instead in the same location under the HKEY_LOCAL_MACHINE key. However, the converse may apply for administrator-enforced policy settings where HKLM may take precedence over HKCU. The Windows Logo Program has specific requirements for where different types of user data may be stored, and that the concept of least privilege be followed so that administrator-level access is not required to use an application.[a][10]
HKEY_LOCAL_MACHINE (HKLM)
[edit]Abbreviated HKLM, HKEY_LOCAL_MACHINE stores settings that are specific to the local computer.[11]
The key located by HKLM is actually not stored on disk, but maintained in memory by the system kernel in order to map all the other subkeys. Applications cannot create any additional subkeys. On Windows NT, this key contains four subkeys, "SAM", "SECURITY", "SYSTEM", and "SOFTWARE", that are loaded at boot time within their respective files located in the %SystemRoot%\System32\config\ folder. A fifth subkey, "HARDWARE", is volatile and is created dynamically, and as such is not stored in a file (it exposes a view of all the currently detected Plug-and-Play devices). On Windows Vista and above, a sixth and seventh subkey, "COMPONENTS" and "BCD", are mapped in memory by the kernel on-demand and loaded from %SystemRoot%\System32\config\COMPONENTS or from boot configuration data, \boot\BCD on the system partition.
- The "
HKLM\SAM" key usually appears as empty for most users (unless they are granted access by administrators of the local system or administrators of domains managing the local system). It is used to reference all "Security Accounts Manager" (SAM) databases for all domains into which the local system has been administratively authorized or configured (including the local domain of the running system, whose SAM database is stored in a subkey also named "SAM": other subkeys will be created as needed, one for each supplementary domain). Each SAM database contains all built in accounts (mostly group aliases) and configured accounts (users, groups and their aliases, including guest accounts and administrator accounts) created and configured on the respective domain, for each account in that domain, it notably contains the user name which can be used to log on that domain, the internal unique user identifier in the domain, a cryptographic hash of each user's password for each enabled authentication protocol, the location of storage of their user registry hive, various status flags (for example if the account can be enumerated and be visible in the logon prompt screen), and the list of domains (including the local domain) into which the account was configured. - The "
HKLM\SECURITY" key usually appears empty for most users (unless they are granted access by users with administrative privileges) and is linked to the Security database of the domain into which the current user is logged on (if the user is logged on the local system domain, this key will be linked to the registry hive stored by the local machine and managed by local system administrators or by the built in "System" account and Windows installers). The kernel will access it to read and enforce the security policy applicable to the current user and all applications or operations executed by this user. It also contains a "SAM" subkey which is dynamically linked to the SAM database of the domain onto which the current user is logged on. - The "
HKLM\SYSTEM" key is normally only writable by users with administrative privileges on the local system. It contains information about the Windows system setup, data for the secure random number generator (RNG), the list of currently mounted devices containing a filesystem, several numbered Control Sets (such as "HKLM\SYSTEM\ControlSet001") containing alternative configurations for system hardware drivers and services running on the local system (including the currently used one and a backup), a "HKLM\SYSTEM\Select" subkey containing the status of these Control Sets, and a "HKLM\SYSTEM\CurrentControlSet" which is dynamically linked at boot time to the Control Set which is currently used on the local system. Each configured Control Set contains:- an "Enum" subkey enumerating all known Plug-and-Play devices and associating them with installed system drivers (and storing the device-specific configurations of these drivers),
- a "Services" subkey listing all installed system drivers (with non device-specific configuration, and the enumeration of devices for which they are instantiated) and all programs running as services (how and when they can be automatically started),
- a "Control" subkey organizing the various hardware drivers and programs running as services and all other system-wide configuration,
- a "Hardware Profiles" subkey enumerating the various profiles that have been tuned (each one with "System" or "Software" settings used to modify the default profile, either in system drivers and services or in the applications) as well as the
Hardware Profiles\Currentsubkey which is dynamically linked to one of these profiles.
- The "
HKLM\SOFTWARE" subkey contains software and Windows settings (in the default hardware profile). It is mostly modified by application and system installers. It is organized by software vendor (with a subkey for each), but also contains a "Windows" subkey for some settings of the Windows user interface, a "Classes" subkey containing all registered associations from file extensions, MIME types, Object Classes IDs and interfaces IDs (for OLE, COM/DCOM and ActiveX), to the installed applications or DLLs that may be handling these types on the local machine (however these associations are configurable for each user, see below), and a "Policies" subkey (also organized by vendor) for enforcing general usage policies on applications and system services (including the central certificates store used for authenticating, authorizing or disallowing remote systems or services running outside the local network domain). - The "
HKLM\SOFTWARE\Wow6432Node" key is used by 32-bit applications on a 64-bit Windows OS, and is equivalent to but separate from "HKLM\SOFTWARE". The key path is transparently presented to 32-bit applications by WoW64 asHKLM\SOFTWARE[12] (in a similar way that 64-bit applications see%SystemRoot%\Syswow64as%SystemRoot%\System32)
HKEY_CLASSES_ROOT (HKCR)
[edit]- Abbreviated HKCR, HKEY_CLASSES_ROOT contains information about registered applications, such as file associations and OLE Object Class IDs, tying them to the applications used to handle these items. On Windows 2000 and above, HKCR is a compilation of user-based
HKCU\Software\Classesand machine-basedHKLM\Software\Classes. If a given value exists in both of the subkeys above, the one inHKCU\Software\Classestakes precedence.[13] The design allows for either machine- or user-specific registration of COM objects.
HKEY_USERS (HKU)
[edit]- Abbreviated HKU, HKEY_USERS contains subkeys corresponding to the HKEY_CURRENT_USER keys for each user profile actively loaded on the machine, though user hives are usually only loaded for currently logged-in users.
HKEY_CURRENT_USER (HKCU)
[edit]- Abbreviated HKCU, HKEY_CURRENT_USER stores settings that are specific to the currently logged-in user.[14] The HKEY_CURRENT_USER key is a link to the subkey of HKEY_USERS that corresponds to the user; the same information is accessible in both locations. The specific subkey referenced is
(HKU)\(SID)\...where (SID) corresponds to the Windows SID; if the "(HKCU)" key has the following suffix(HKCU)\Software\Classes\...then it corresponds to(HKU)\(SID)_CLASSES\...i.e. the suffix string "_CLASSES" is appended to the (SID).
- On Windows NT systems, each user's settings are stored in their own files called NTUSER.DAT and USRCLASS.DAT inside their own Documents and Settings subfolder (or their own Users sub folder in Windows Vista and above). Settings in this hive follow users with a roaming profile from machine to machine.
HKEY_PERFORMANCE_DATA
[edit]- This key provides runtime information into performance data provided by either the NT kernel itself, or running system drivers, programs and services that provide performance data. This key is not stored in any hive and not displayed in the Registry Editor, but it is visible through the registry functions in the Windows API, or in a simplified view via the Performance tab of the Task Manager (only for a few performance data on the local system) or via more advanced control panels (such as the Performances Monitor or the Performances Analyzer which allows collecting and logging these data, including from remote systems).
HKEY_DYN_DATA
[edit]- This key is used only in Windows 95, Windows 98 and Windows ME.[15] It contains information about hardware devices, including Plug and Play and network performance statistics. The information in this hive is also not stored on the hard drive; the Plug and Play information is gathered and configured at startup and is stored in memory.[16]
Hives
[edit]Even though the registry presents itself as an integrated hierarchical database, branches of the registry are actually stored in a number of disk files called hives.[17] (The word hive constitutes an in-joke.)[18]
Some hives are volatile and are not stored on disk at all. An example of this is the hive of the branch starting at HKLM\HARDWARE. This hive records information about system hardware and is created each time the system boots and performs hardware detection.
Individual settings for users on a system are stored in a hive (disk file) per user. During user login, the system loads the user hive under the HKEY_USERS key and sets the HKCU (HKEY_CURRENT_USER) symbolic reference to point to the current user. This allows applications to store/retrieve settings for the current user implicitly under the HKCU key.
Not all hives are loaded at any one time. At boot time, only a minimal set of hives are loaded, and after that, hives are loaded as the operating system initializes and as users log in or whenever a hive is explicitly loaded by an application.
File locations
[edit]The registry is physically stored in several files, which are generally obfuscated from the user-mode APIs used to manipulate the data inside the registry. Depending upon the version of Windows, there will be different files and different locations for these files, but they are all on the local machine. The location for system registry files in Windows NT is %SystemRoot%\System32\config\; the user-specific HKEY_CURRENT_USER user registry hive is stored in Ntuser.dat inside the user profile. There is one of these per user; if a user has a roaming profile, then this file will be copied to and from a server at logout and login respectively. A second user-specific registry file named UsrClass.dat contains COM registry entries and does not roam by default.
Windows NT
[edit]Windows NT systems store the registry in a binary file format which can be exported, loaded and unloaded by the Registry Editor in these operating systems. The following system registry files are stored in %SystemRoot%\System32\config\:
Sam–HKEY_LOCAL_MACHINE\SAMSecurity–HKEY_LOCAL_MACHINE\SECURITYSoftware–HKEY_LOCAL_MACHINE\SOFTWARESystem–HKEY_LOCAL_MACHINE\SYSTEMDefault–HKEY_USERS\.DEFAULTUserdiff– Not associated with a hive. Used only when upgrading operating systems.[19]
The following file is stored in each user's profile folder:
%USERPROFILE%\Ntuser.dat–HKEY_USERS\<User SID>(linked to by HKEY_CURRENT_USER)
For Windows 2000, Server 2003 and Windows XP, the following additional user-specific file is used for file associations and COM information:
%USERPROFILE%\Local Settings\Application Data\Microsoft\Windows\Usrclass.dat(path is localized) –HKEY_USERS\<User SID>_Classes(HKEY_CURRENT_USER\Software\Classes)
For Windows Vista and later, the path was changed to:
%USERPROFILE%\AppData\Local\Microsoft\Windows\Usrclass.dat(path is not localized) alias%LocalAppData%\Microsoft\Windows\Usrclass.dat– HKEY_USERS\<User SID>_Classes (HKEY_CURRENT_USER\Software\Classes)
Windows 2000 keeps an alternate copy of the registry hives (.ALT) and attempts to switch to it when corruption is detected.[20] Windows XP and Windows Server 2003 do not maintain a System.alt hive because NTLDR on those versions of Windows can process the System.log file to bring up to date a System hive that has become inconsistent during a shutdown or crash. In addition, the %SystemRoot%\Repair folder contains a copy of the system's registry hives that were created after installation and the first successful startup of Windows.
Each registry data file has an associated file with a ".log" extension that acts as a transaction log that is used to ensure that any interrupted updates can be completed upon next startup.[21] Internally, Registry files are split into 4 kB "bins" that contain collections of "cells".[21]
Windows 9x
[edit]The registry files are stored in the %WINDIR% directory under the names USER.DAT and SYSTEM.DAT with the addition of CLASSES.DAT in Windows ME. Also, each user profile (if profiles are enabled) has its own USER.DAT file which is located in the user's profile directory in %WINDIR%\Profiles\<Username>\.
Windows 3.11
[edit]The only registry file is called REG.DAT and it is stored in the %WINDIR% directory.
Windows 10 Mobile
[edit]To access the registry files, the device needs to be set in a special mode using either:
- WpInternals (Put the device into flash mode.)
- InterOp Tools (Mount the MainOS Partition with MTP.)
If any of the above methods worked, the device's registry files can be found in the following location:
{Phone}\EFIESP\Windows\System32\config
Editing
[edit]Registry editors
[edit]The registry contains important configuration information for the operating system, for installed applications as well as individual settings for each user and application. A careless change to the operating system configuration in the registry could cause irreversible damage, so it is usually only installer programs which perform changes to the registry database during installation/configuration and removal. If a user wants to edit the registry manually, Microsoft recommends that a backup of the registry be performed before the change.[22] When a program is removed from control panel, it may not be completely removed and, in case of errors or glitches caused by references to missing programs, the user might have to manually check inside directories such as program files. After this, the user might need to manually remove any reference to the uninstalled program in the registry. This is usually done by using RegEdit.exe.[23] Editing the registry is sometimes necessary when working around Windows-specific issues e.g. problems when logging onto a domain can be resolved by editing the registry.[24]
Windows Registry can be edited manually using programs such as RegEdit.exe, although these tools do not expose some of the registry's metadata such as the last modified date.
The registry editor for the 3.1/95 series of operating systems is RegEdit.exe and for Windows NT it is RegEdt32.exe; the functionalities are merged in Windows XP. Optional and third-party tools similar to RegEdit.exe are available for many Windows CE versions.
Registry Editor allows users to perform the following functions:
- Creating, manipulating, renaming[25] and deleting registry keys, subkeys, values and value data
- Importing and exporting
.REGfiles, exporting data in the binary hive format - Loading, manipulating and unloading registry hive format files (Windows NT systems only)
- Setting permissions based on ACLs (Windows NT systems only)
- Bookmarking user-selected registry keys as Favorites
- Finding particular strings in key names, value names and value data
- Remotely editing the registry on another networked computer
.REG files
[edit].REG files (also known as Registration entries) are text-based human-readable files for exporting and importing portions of the registry using an INI-based syntax. There are two main versions of REG files:
- Windows 9x and NT 4.0 REG files are ANSI-based. They start with the string
REGEDIT4.[26] - Windows 2000 and later REG files are Unicode-based. They start with the string Windows Registry Editor Version 5.00.
Windows 9x format .REG files can be imported by Windows 2000 and later.[26] These later systems also allow exporting .REG files in Windows 9x/NT format.[citation needed]
Data is stored in .REG files using the following syntax:[26]
[<Hive name>\<Key name>\<Subkey name>]
"Value name"=<Value type>:<Value data>
The Default Value of a key can be edited by using @ instead of "Value Name":
[<Hive name>\<Key name>\<Subkey name>]
@=<Value type>:<Value data>
String values do not require a <Value type> (see example), but backslashes (\) need to be written as a double-backslash (\\), and quotes (") as backslash-quote (\"). (The requirement for escaping is not totally consistent: files containing strings with unescaped leading backslash do exist and are accepted by the system for importing.)[27]
For example, to add the values "Value A", "Value B", etc. to the HKLM\SOFTWARE\Foobar key:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Foobar]
"Value A"="<String value data with escape characters>"
"Value B"=hex:<Binary data (as comma-delimited list of hexadecimal values)>
"Value C"=dword:<DWORD value integer>
"Value D"=hex(0):<REG_NONE (as comma-delimited list of hexadecimal values)>
"Value E"=hex(1):<REG_SZ (as comma-delimited list of hexadecimal values representing a UTF-16LE NUL-terminated string)>
"Value F"=hex(2):<Expandable string value data (as comma-delimited list of hexadecimal values representing a UTF-16LE NUL-terminated string)>
"Value G"=hex(3):<Binary data (as comma-delimited list of hexadecimal values)> ; equal to "Value B"
"Value H"=hex(4):<DWORD value (as comma-delimited list of 4 hexadecimal values, in little endian byte order)>
"Value I"=hex(5):<DWORD value (as comma-delimited list of 4 hexadecimal values, in big endian byte order)>
"Value J"=hex(7):<Multi-string value data (as comma-delimited list of hexadecimal values representing UTF-16LE NUL-terminated strings)>
"Value K"=hex(8):<REG_RESOURCE_LIST (as comma-delimited list of hexadecimal values)>
"Value L"=hex(a):<REG_RESOURCE_REQUIREMENTS_LIST (as comma-delimited list of hexadecimal values)>
"Value M"=hex(b):<QWORD value (as comma-delimited list of 8 hexadecimal values, in little endian byte order)>
Data from .REG files can be added/merged with the registry by double-clicking these files or using the /s switch in the command line. REG files can also be used to remove registry data.
To remove a key (and all subkeys, values and data), the key name must be preceded by a minus sign (-).[26]
For example, to remove the HKLM\SOFTWARE\Foobar key (and all subkeys, values and data),
[-HKEY_LOCAL_MACHINE\SOFTWARE\Foobar]
To remove a value (and its data), the values to be removed must have a minus sign (-) after the equal sign (=).[26]
For example, to remove only the "Value A" and "Value B" values (and their data) from the HKLM\SOFTWARE\Foobar key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Foobar]
"Value A"=-
"Value B"=-
To remove only the Default value of the key HKLM\SOFTWARE\Foobar (and its data):
[HKEY_LOCAL_MACHINE\SOFTWARE\Foobar]
@=-
Lines beginning with a semicolon are considered comments:
; This is a comment. This can be placed in any part of a .reg file
[HKEY_LOCAL_MACHINE\SOFTWARE\Foobar]
"Value"="Example string"
Group policies
[edit]Windows group policies can change registry keys for a number of machines or individual users based on policies. When a policy first takes effect for a machine or for an individual user of a machine, the registry settings specified as part of the policy are applied to the machine or user settings.
Windows will also look for updated policies and apply them periodically, typically every 90 minutes.[28]
Through its scope a policy defines to which machines and users the policy is to be applied. Whether a machine or user is within the scope of a policy or not is defined by a set of rules which can filter on the location of the machine or user account in organizational directory, specific users or machine accounts or security groups. More advanced rules can be set up using Windows Management Instrumentation expressions. Such rules can filter on properties such as computer vendor name, CPU architecture, installed software, or networks connected to.
For instance, the administrator can create a policy with one set of registry settings for machines in the accounting department and policy with another (lock-down) set of registry settings for kiosk terminals in the visitors area. When a machine is moved from one scope to another (e.g., changing its name or moving it to another organizational unit), the correct policy is automatically applied. When a policy is changed it is automatically re-applied to all machines currently in its scope.
The policy is edited through a number of administrative templates which provides a user interface for picking and changing settings. The set of administrative templates is extensible and software packages which support such remote administration can register their own templates.
Command line editing
[edit]| reg | |
|---|---|
| Developer | Microsoft |
| Operating system | Microsoft Windows |
| Type | Command |
| License | Proprietary commercial software |
| Website | docs |
| regini | |
|---|---|
| Developer | Microsoft |
| Operating system | Microsoft Windows |
| Type | Command |
| License | Proprietary commercial software |
| Website | docs |
The registry can be manipulated in a number of ways from the command line. The Reg.exe and RegIni.exe utility tools are included in Windows XP and later versions of Windows. Alternative locations for legacy versions of Windows include the Resource Kit CDs or the original Installation CD of Windows.
Also, a .REG file can be imported from the command line with the following command:
RegEdit.exe /s file
The /s means the file will be silent merged to the registry. If the /s parameter is omitted the user will be asked to confirm the operation. In Windows 98, Windows 95 and at least some configurations of Windows XP the /s switch also causes RegEdit.exe to ignore the setting in the registry that allows administrators to disable it. When using the /s switch RegEdit.exe does not return an appropriate return code if the operation fails, unlike Reg.exe which does.
RegEdit.exe /e file
exports the whole registry in V5 format to a UNICODE .REG file, while any of
RegEdit.exe /e file HKEY_CLASSES_ROOT[\<key>] RegEdit.exe /e file HKEY_CURRENT_CONFIG[\<key>] RegEdit.exe /e file HKEY_CURRENT_USER[\<key>] RegEdit.exe /e file HKEY_LOCAL_MACHINE[\<key>] RegEdit.exe /e file HKEY_USERS[\<key>]
export the specified (sub)key (which has to be enclosed in quotes if it contains spaces) only.
RegEdit.exe /a file
exports the whole registry in V4 format to an ANSI .REG file.
RegEdit.exe /a file <key>
exports the specified (sub)key (which has to be enclosed in quotes if it contains spaces) only.
It is also possible to use Reg.exe. Here is a sample to display the value of the registry value Version:
Reg.exe QUERY HKLM\Software\Microsoft\ResKit /v Version
Other command line options include a VBScript or JScript together with CScript, WMI or WMIC.exe and Windows PowerShell.
Registry permissions can be manipulated through the command line using RegIni.exe and the SubInACL.exe tool. For example, the permissions on the HKEY_LOCAL_MACHINE\SOFTWARE key can be displayed using:
SubInACL.exe /keyreg HKEY_LOCAL_MACHINE\SOFTWARE /display
PowerShell commands and scripts
[edit]
Windows PowerShell comes with a registry provider which presents the registry as a location type similar to the file system. The same commands used to manipulate files and directories in the file system can be used to manipulate keys and values of the registry.[29]
Also like the file system, PowerShell uses the concept of a current location which defines the context on which commands by default operate. The Get-ChildItem (also available through the aliases ls, dir or gci) retrieves the child keys of the current location. By using the Set-Location (or the alias cd) command the user can change the current location to another key of the registry.[29] Commands which rename items, remove items, create new items or set content of items or properties can be used to rename keys, remove keys or entire sub-trees or change values.
Through PowerShell scripts files, an administrator can prepare scripts which, when executed, make changes to the registry. Such scripts can be distributed to administrators who can execute them on individual machines. The PowerShell Registry provider supports transactions, i.e. multiple changes to the registry can be bundled into a single atomic transaction. An atomic transaction ensures that either all of the changes are committed to the database, or if the script fails, none of the changes are committed to the database.[29][30]
Programs or scripts
[edit]The registry can be edited through the APIs of the Advanced Windows 32 Base API Library (advapi32.dll).[31] List of registry API functions:
- RegCloseKey
- RegConnectRegistry
- RegCreateKey
- RegCreateKeyEx
- RegDeleteKey
- RegDeleteValue
- RegEnumKey
- RegEnumKeyEx
- RegEnumValue
- RegFlushKey
- RegGetKeySecurity
- RegLoadKey
- RegNotifyChangeKeyValue
- RegOpenKey
- RegOpenKeyEx
- RegQueryInfoKey
- RegQueryMultipleValues
- RegQueryValue
- RegQueryValueEx
- RegReplaceKey
- RegRestoreKey
- RegSaveKey
- RegSetKeySecurity
- RegSetValue
- RegSetValueEx
- RegUnLoadKey
Many programming languages offer built-in runtime library functions or classes that wrap the underlying Windows APIs and thereby enable programs to store settings in the registry (e.g. Microsoft.Win32.Registry in VB.NET and C#, or TRegistry in Delphi and Free Pascal). COM-enabled applications like Visual Basic 6 can use the WSH WScript.Shell object. Another way is to use the Windows Resource Kit Tool, Reg.exe by executing it from code,[32] although this is considered poor programming practice.
Similarly, scripting languages such as Perl (with Win32::TieRegistry), Python (with winreg), TCL (which comes bundled with the registry package),[33] Windows Powershell and Windows Scripting Host also enable registry editing from scripts.
Offline editing
[edit]The offreg.dll[34] available from the Windows Driver Kit offers a set of APIs for the creation and manipulation of currently not loaded registry hives similar to those provided by advapi32.dll.
It is also possible to edit the registry (hives) of an offline system from Windows PE or Linux (in the latter case using open source tools).
COM self-registration
[edit]Prior to the introduction of registration-free COM, developers were encouraged to add initialization code to in-process and out-of-process binaries to perform the registry configuration required for that object to work. For in-process binaries such as .DLL and .OCX files, the modules typically exported a function called DllInstall()[35] that could be called by installation programs or invoked manually with utilities like Regsvr32.exe;[36] out-of-process binaries typically support the commandline arguments /Regserver and /Unregserver that created or deleted the required registry settings.[37] COM applications that break because of DLL Hell issues can commonly be repaired with RegSvr32.exe or the /RegServer switch without having to re-invoke installation programs.[38]
Advanced functionality
[edit]Windows exposes APIs that allows user-mode applications to register to receive a notification event if a particular registry key is changed.[39] APIs are also available to allow kernel-mode applications to filter and modify registry calls made by other applications.[40]
Windows also supports remote access to the registry of another computer via the RegConnectRegistry function[41] if the Remote Registry service is running, correctly configured and its network traffic is not firewalled.[42]
Security
[edit]Each key in the registry of Windows NT versions can have an associated security descriptor. The security descriptor contains an access control list (ACL) that describes which user groups or individual users are granted or denied access permissions. The set of registry permissions include 10 rights/permissions which can be explicitly allowed or denied to a user or a group of users.
| Permission | Description |
|---|---|
| Query Value | The right to read the registry key value. |
| Set Value | The right to write a new value |
| Create Subkey | The right to create subkeys. |
| Enumerate Subkeys | Allow the enumeration of subkeys. |
| Notify | The right to request change notifications for registry keys or subkeys. |
| Create Link | Reserved by the operating system. |
| Delete | The right to delete a key. |
| Write DACL | The right to modify permissions of the container's DACL. |
| Write Owner | The right to modify the container's owner. |
| Read Control | The right to read the DACL. |
As with other securable objects in the operating system, individual access control entries (ACE) on the security descriptor can be explicit or inherited from a parent object.[43]
Windows Resource Protection is a feature of Windows Vista and later versions of Windows that uses security to deny Administrators and the system WRITE access to some sensitive keys to protect the integrity of the system from malware and accidental modification.[44]
Special ACEs on the security descriptor can also implement mandatory integrity control for the registry key and subkeys. A process running at a lower integrity level cannot write, change or delete a registry key/value, even if the account of the process has otherwise been granted access through the ACL. For instance, Internet Explorer running in Protected Mode can read medium and low integrity registry keys/values of the currently logged on user, but it can only modify low integrity keys.[45]
Outside security, registry keys cannot be deleted or edited due to other causes. Registry keys containing NUL characters cannot be deleted with standard registry editors and require a special utility for deletion, such as RegDelNull.[46][47]
Backups and recovery
[edit]Different editions of Windows have supported a number of different methods to back up and restore the registry over the years, some of which are now deprecated:
- System Restore can back up the registry and restore it as long as Windows is bootable, or from the Windows Recovery Environment (starting with Windows Vista).
- NTBackup can back up the registry as part of the System State and restore it. Automated System Recovery in Windows XP can also restore the registry.
- On Windows NT, the Last Known Good Configuration option in startup menu relinks the
HKLM\SYSTEM\CurrentControlSetkey, which stores hardware and device driver information. - Windows 98 and Windows ME include command line (Scanreg.exe) and GUI (Scanregw.exe) registry checker tools to check and fix the integrity of the registry, create up to five automatic regular backups by default and restore them manually or whenever corruption is detected.[48] The registry checker tool backs up the registry, by default, to
%Windir%\SysbckupScanreg.exe can also run from MS-DOS.[49] - The Windows 95 CD-ROM included an Emergency Recovery Utility (ERU.exe) and a Configuration Backup Tool (Cfgback.exe) to back up and restore the registry. Additionally Windows 95 backs up the registry to the files system.da0 and user.da0 on every successful boot.
- Windows NT 4.0 included
RDISK.EXE, a utility to back up and restore the entire registry.[50] - Windows 2000 Resource Kit contained an unsupported pair of utilities called Regback.exe and RegRest.exe for backup and recovery of the registry.[51]
- Periodic automatic backups of the registry are now disabled by default on Windows 10 May 2019 Update (version 1903). Microsoft recommends System Restore be used instead.[52]
Policy
[edit]Group policy
[edit]Windows 2000 and later versions of Windows use Group Policy to enforce registry settings through a registry-specific client extension in the Group Policy processing engine.[53] Policy may be applied locally to a single computer using gpedit.msc or to multiple users and computers in a domain using gpmc.msc.
Legacy systems
[edit]With Windows 95, Windows 98, Windows ME and Windows NT 4.0, administrators can use a special file to be merged into the registry, called a policy file (POLICY.POL). The policy file allows administrators to prevent non-administrator users from changing registry settings like, for instance, the security level of Internet Explorer and the desktop background wallpaper. The policy file is primarily used in a business with a large number of computers where the business needs to be protected from rogue or careless users.
The default extension for the policy file is .POL.
The policy file filters the settings it enforces by user and by group (a "group" is a defined set of users). To do that the policy file merges into the registry, preventing users from circumventing it by simply changing back the settings.
The policy file is usually distributed through a LAN, but can be placed on the local computer.
The policy file is created by a free tool by Microsoft that goes by the filename poledit.exe for Windows 95/Windows 98 and with a computer management module for Windows NT. The editor requires administrative permissions to be run on systems that uses permissions.
The editor can also directly change the current registry settings of the local computer and if the remote registry service is installed and started on another computer it can also change the registry on that computer.
The policy editor loads the settings it can change from .ADM files, of which one is included, that contains the settings the Windows shell provides. The .ADM file is plain text and supports easy localization by allowing all the strings to be stored in one place.
Virtualization
[edit]INI file virtualization
[edit]Windows NT kernels support redirection of INI file-related APIs into a virtual file in a registry location such as HKEY_CURRENT_USER using a feature called "InifileMapping".[54] This functionality was introduced to allow legacy applications written for 16-bit versions of Windows to be able to run under Windows NT platforms on which the System folder is no longer considered an appropriate location for user-specific data or configuration. Non-compliant 32-bit applications can also be redirected in this manner, even though the feature was originally intended for 16-bit applications.
Registry virtualization
[edit]Windows Vista introduced limited registry virtualization, whereby poorly written applications that do not respect the principle of least privilege and instead try to write user data to a read-only system location (such as the HKEY_LOCAL_MACHINE hive), are silently redirected to a more appropriate location, without changing the application itself.
Similarly, application virtualization redirects all of an application's invalid registry operations to a location such as a file. Used together with file virtualization, this allows applications to run on a machine without being installed on it.
Low integrity processes may also use registry virtualization. For example, Internet Explorer 7 or 8 running in "Protected Mode" on Windows Vista and above will automatically redirect registry writes by ActiveX controls to a sandboxed location in order to frustrate some classes of security exploits.
The Application Compatibility Toolkit[55] provides shims that can transparently redirect HKEY_LOCAL_MACHINE or HKEY_CLASSES_ROOT Registry operations to HKEY_CURRENT_USER to address "LUA" bugs that cause applications not to work for users with insufficient rights.
Disadvantages
[edit]Critics labeled the registry in Windows 95 a single point of failure, because re-installation of the operating system was required if the registry became corrupt. However, Windows NT uses transaction logs to protect against corruption during updates. Current versions of Windows use two levels of log files to ensure integrity even in the case of power failure or similar catastrophic events during database updates.[56] Even in the case of a non-recoverable error, Windows can repair or re-initialize damaged registry entries during system boot.[56]
Richard WM Jones, author of libguestfs and hivex (tool to read and write the registry from systems other than the host Windows installation, including non-Windows systems), makes the following critiques:[27]
- Compared to a database with features such as indexed columns, the registry with its concepts of directories (keys), files (values), and extended attributes (permissions) is more of a file system, and an incomplete one at that. Lack of column indexing has lead to the proliferation of oddly-named keys such as
\ControlSet001\Control\CriticalDeviceDatabase\pci#ven_1af4&dev_1001&subsys_00000000. - The hive format is based on the struct layout of the original compiler in the 1990s. The reader implementation in Windows performs insufficient validation, being easy to make to hang or crash by incorrect pointer structures (reference loops, out-of-range pointers). The writer implementation does not properly zero out unused memory, leaking kernel data structures into unused parts of the registry.
- Different versions of Windows have different ideas about what each "type" in the registry refers to. String types such as
REG_SZwere originally stored in 7-bit ASCII, before being switched to UTF-16LE later, so to properly read and write a hive one would need to know the Windows version it is associated with.
Equivalents and alternatives
[edit]This section needs additional citations for verification. (November 2010) |
In Windows, use of the registry for storing program data is a matter of developer's discretion. Microsoft provides programming interfaces for storing data in XML files (via MSXML) or database files (via SQL Server Compact) which developers can use instead. Developers are also free to use non-Microsoft alternatives or develop their own proprietary data stores.
In contrast to Windows Registry's binary-based database model, some other operating systems use separate plain-text files for daemon and application configuration, but group these configurations together for ease of management.
- In Unix-like operating systems (including Linux) that follow the Filesystem Hierarchy Standard, system-wide configuration files (information similar to what would appear in HKEY_LOCAL_MACHINE on Windows) are traditionally stored in files in
/etc/and its subdirectories, or sometimes in/usr/local/etc/. Per-user information (information that would be roughly equivalent to that in HKEY_CURRENT_USER) is stored in hidden directories and files (that start with a period/full stop) within the user's home directory. However XDG-compliant applications should refer to the environment variables defined in the Base Directory specification.[57] - In macOS, system-wide configuration files are typically stored in the
/Library/folder, whereas per-user configuration files are stored in the corresponding~/Library/folder in the user's home directory, and configuration files set by the system are in/System/Library/. Within these respective directories, an application typically stores a property list file in thePreferences/sub-directory. - RISC OS (not to be confused with MIPS RISC/os) uses directories for configuration data, which allows applications to be copied into application directories, as opposed to the separate installation process that typifies Windows applications; this approach is also used on the ROX Desktop for Linux.[58] This directory-based configuration also makes it possible to use different versions of the same application, since the configuration is done "on the fly".[59] If one wishes to remove the application, it is possible to simply delete the folder belonging to the application.[60][61] This will often not remove configuration settings which are stored independently from the application, usually within the computer's !Boot structure, in !Boot Choices or potentially anywhere on a network fileserver. It is possible to copy installed programs between computers running RISC OS by copying the application directories belonging to the programs, however some programs may require re-installing, e.g. when shared files are placed outside an application directory.[59]
- IBM AIX (a Unix variant) uses a registry component called Object Data Manager (ODM). The ODM is used to store information about system and device configuration. An extensive set of tools and utilities provides users with means of extending, checking, correcting the ODM database. The ODM stores its information in several files, default location is
/etc/objrepos. - The GNOME desktop environment uses a registry-like interface called dconf for storing configuration settings for the desktop and applications.
- The Elektra Initiative provides alternative back-ends for various different text configuration files.
- While not an operating system, the Wine compatibility layer, which allows Windows software to run on a Unix-like system, also employs a Windows-like registry as text files in the WINEPREFIX folder: system.reg (HKEY_LOCAL_MACHINE), user.reg (HKEY_CURRENT_USER) and userdef.reg.[62] The format is virtually the same as those of Windows
.REGfiles, except that the header line is changed to "WINE REGISTRY Version 2" and paths (keys) do not start with the name of the hive.
See also
[edit]- Registry cleaner
- Logparser – SQL-like querying of various types of log files
- List of shell icon overlay identifiers
- Ransomware attack that uses Registry
Notes
[edit]- ^ When applications fail to execute because they request more privileges than they require (and are denied those privileges), this is known as a limited user application (LUA) bug.
Footnotes
[edit]- ^ Esposito, Dino (November 2000). "Windows 2000 Registry: Latest Features and APIs Provide the Power to Customize and Extend Your Apps". MSDN Magazine. Microsoft. Archived from the original on April 15, 2003. Retrieved July 19, 2007.
- ^ a b c "The System Registry".
- ^ "Windows 95 Architecture Components". www.microsoft.com. Archived from the original on February 7, 2008. Retrieved April 29, 2008.
The following table shows other difficulties or limitations caused by using .INI files that are overcome by using the Registry.
- ^ Hipson 2002, p. 5, 41–43.
- ^ Richter, Jeffrey; Nasarre, Christophe (2008). Windows Via C/C++ (Fifth ed.). Microsoft Press. ISBN 9780735642461. Retrieved August 28, 2021.
- ^ Raymond Chen, "Why do registry keys have a default value?"
- ^ Hipson 2002, pp. 207, 513–514.
- ^ Hipson 2002, pp. 520–521.
- ^ Hipson 2002, p. 7.
- ^ "Designed for Windows XP Application Specification". Microsoft. August 20, 2002. Retrieved April 8, 2009.
- ^ "HKEY_LOCAL_MACHINE". Gautam. 2009. Retrieved April 8, 2009.
- ^ "Registry Keys Affected by WOW64 (Windows)". Msdn.microsoft.com. Retrieved April 10, 2014.
- ^ "Description of the Microsoft Windows registry". Retrieved September 25, 2008.
- ^ "HKEY_CURRENT_USER". Microsoft. 2009. Retrieved April 8, 2009.
- ^ "Description of the HKEY_DYN_DATA Registry Key in Windows 95, Windows 98, and Windows 98 SE". support.microsoft.com.
- ^ "A Closer Look at HKEY_DYN_DATA". rinet.ru. Archived from the original on May 9, 2008.
- ^ "Registry hives". Retrieved July 19, 2007.
- ^ Chen, Raymond (August 8, 2011). "Why is a registry file called a "hive"?". The Old New Thing. Retrieved July 29, 2011.
- ^ "Overview of the Windows NT Registry". Retrieved December 2, 2011.
- ^ "Inside the Registry". Retrieved December 28, 2007.
- ^ a b Norris, Peter (February 2009). "The Internal Structure of the Windows Registry" (PDF). Cranfield University. Archived from the original (PDF) on May 29, 2009.
- ^ "Incorrect Icons Displayed for .ico Files". November 15, 2009. Retrieved March 31, 2012.
- ^ "How to Completely Uninstall / Remove a Software Program in Windows without using 3rd Party Software? - AskVG". www.askvg.com. August 26, 2011.
- ^ "You may receive a "STOP 0x00000035 NO_MORE_IRP_STACK_LOCATIONS" error message when you try to log on to a domain". October 9, 2011. Retrieved March 31, 2012. This page tells the user to edit the registry when resolving the issue.
- ^ key renaming is implemented as removal and add while retaining subkeys/values, as the underlying APIs do not support the rename function directly
- ^ a b c d e "How to add, modify, or delete registry subkeys and values by using a .reg file". support.microsoft.com.
- ^ a b "Why the Windows Registry sucks … technically". Richard WM Jones. February 18, 2010.
- ^ "Applying Group Policy". Microsoft.
- ^ a b c Payette, Bruce; Siddaway, Richard (2018). Windows PowerShell in Action (Third ed.). Manning Publications. pp. 7–8, 24, 608, 708–710. ISBN 9781633430297. Retrieved August 28, 2021.
- ^ Warner, Timothy L. (May 2015). Windows PowerShell in 24 Hours, Sams Teach Yourself. Sams Publishing. p. 19, 211. ISBN 9780134049359. Retrieved August 28, 2021.
- ^ "Reading and Writing Registry Values with Visual Basic". Retrieved July 19, 2007.
- ^ "REG command in Windows XP". Retrieved July 19, 2007.
- ^ "registry manual page – Tcl Bundled Packages". www.tcl.tk. Retrieved December 14, 2017.
- ^ "Offline Registry Library". Retrieved June 4, 2014.
- ^ "DllInstall Function". Microsoft. March 7, 2012. Retrieved March 22, 2012.
- ^ "Regsvr32". Microsoft. Retrieved March 22, 2012.
- ^ "How to: Register Automation Servers". Microsoft. Retrieved March 22, 2012.
- ^ "How to re-register PowerPoint 2000, PowerPoint 2003, PowerPoint 2007 and PowerPoint 2010". Microsoft. January 2012. Retrieved March 22, 2012.
- ^ "RegNotifyChangeKeyValue function". Microsoft.
- ^ "Registering for Notifications". Microsoft.
- ^ "RegConnectRegistry function". Microsoft.
- ^ "How to Manage Remote Access to the Registry". Microsoft.
- ^ Gibson, Darril (June 28, 2011). "Chapter 4: Securing Access with Permissions". Microsoft Windows security : essentials. Indianapolis, Ind.: Wiley. ISBN 978-1-118-01684-8.
- ^ "Application Compatibility: Windows Resource Protection (WRP)". Microsoft. Retrieved August 8, 2012.
- ^ Marc Silbey, Peter Brundrett. "Understanding and Working in Protected Mode Internet Explorer". Retrieved August 8, 2012.
- ^ "RegDelNull v1.1". November 1, 2006. Retrieved August 8, 2012.
- ^ "Unable to delete certain registry keys – Error while deleting key". March 23, 2010. Retrieved August 8, 2012. Microsoft Support page.
- ^ "Description of the Windows Registry Checker Tool (Scanreg.exe)".
- ^ "Command-Line Switches for the Registry Checker Tool".
- ^ "How To Backup, Edit, and Restore the Registry in Windows NT 4.0". support.microsoft.com.
- ^ "Technical Reference to the Registry: Related Resources". Microsoft. Retrieved September 9, 2011.
- ^ Whitwam, Ryan (July 2019). "Microsoft Kills Automatic Registry Backups in Windows 10". ExtremeTech. Retrieved July 1, 2019.
- ^ "How Core Group Policy Works". Microsoft. September 2, 2009. Retrieved August 13, 2012.
- ^ "Chapter 26 – Initialization Files and the Registry". Microsoft. Retrieved March 3, 2008.
- ^ "Microsoft Application Compatibility Toolkit 5.0". Microsoft. Retrieved July 26, 2008.
- ^ a b Ionescu, Mark Russinovich, David A. Solomon, Alex (2012). "Registry Internals". Windows internals (6th ed.). Redmond, Wash.: Microsoft Press. ISBN 978-0-7356-4873-9.
{{cite book}}: CS1 maint: multiple names: authors list (link) - ^ "XDG Base Directory Specification". standards.freedesktop.org.
- ^ "Application directories". Archived from the original on May 27, 2012. Retrieved May 17, 2012.
- ^ a b "Case Studies Of The Top 132 Annoyances With Operating Systems Other Than RISC OS". Retrieved April 3, 2012. Page from the riscos.com website. Mentioned in points 82 and 104.
- ^ "RISC OS tour". Retrieved July 19, 2007.
- ^ "The RISC OS Products Directory". November 2, 2006. Archived from the original on February 19, 2007. Retrieved April 1, 2012.
- ^ 3.2. Using the Registry and Regedit (Wine User Guide)
References
[edit]- Hipson, Peter (2002). Mastering Windows XP Registry. Wiley. ISBN 0-7821-2987-0. Retrieved August 28, 2021.
- Russinovich, Mark E.; Solomon, David A. (2005). Microsoft Windows Internals (Fourth ed.). Microsoft Press. pp. 183–236. ISBN 978-0-7356-1917-3.
External links
[edit]- Windows Registry info & reference in the MSDN Library
Windows Registry
View on GrokipediaHistory and Rationale
Development Origins
The Windows Registry originated as a simple configuration store in Windows 3.1, released on April 6, 1992, where it replaced scattered initialization (INI) files by centralizing settings for Component Object Model (COM)-based components in a single REG.DAT file limited to 64 KB in size.[8] This initial implementation provided a hierarchical structure for 16-bit applications but was primarily used for basic system and program preferences, marking the shift from fragmented text-based files to a more organized database format.[7] In Windows 95, launched on August 24, 1995, and its successor Windows 98, the Registry evolved into a more robust central repository for both hardware profiles and software configurations, expanding beyond COM to encompass Plug and Play device settings and user preferences stored across multiple hive files like SYSTEM.DAT and USER.DAT.[7] This version introduced enhanced backup mechanisms, such as automatic daily snapshots via ScanReg, to mitigate corruption risks in the growing database, reflecting the increasing complexity of 32-bit applications and peripherals.[9] The Windows NT lineage introduced a major overhaul with Windows NT 3.1 on July 27, 1993, redesigning the Registry for enterprise-grade security, stability, and multi-user support by separating machine-specific data (e.g., in SYSTEM and SOFTWARE hives) from user profiles, stored in secure files like %SystemRoot%\System32\Config.[10] This architecture emphasized access controls and remote administration, diverging from the consumer-focused 9x series, which included volatile elements like HKEY_DYN_DATA—a dynamic performance data hive unique to Windows 95/98/ME. NT-based systems, from Windows NT 3.1 onward, omitted this hive in favor of HKEY_PERFORMANCE_DATA to enhance reliability and stability.[11] Subsequent updates in Windows XP, released October 25, 2001, improved Registry performance through optimized hive loading and better integration with features like Fast User Switching, while introducing x64-specific redirects in 64-bit editions to isolate 32-bit and native applications.[12] In Windows 10 (2015) and Windows 11 (October 5, 2021), the Registry adapted to cloud integration, enabling synchronization of user settings via Microsoft accounts and the Settings app, which pulls and pushes select keys to Azure-based services for cross-device consistency.[13] To support ARM-based devices since Windows 10 on ARM in 2017, the Registry incorporates architecture-specific keys under HKEY_LOCAL_MACHINE\HARDWARE for processor and driver configurations, ensuring compatibility with emulation layers like WoA (Windows on ARM) while maintaining the core hierarchical model.[14]Design Principles
The Windows Registry was designed as a centralized, hierarchical database to consolidate fragmented configuration data previously stored in numerous text-based .ini files and other system files, such as those used in Windows 3.x and MS-DOS environments like AUTOEXEC.BAT and CONFIG.SYS, thereby simplifying management and enabling efficient searching across settings.[7] This approach addressed the limitations of scattered files by providing a unified repository for low-level operating system and application settings, reducing administrative overhead and improving system integrity through features like atomic updates.[2] The core structure draws inspiration from filesystem directories, organizing data into a tree of keys and subkeys that allow settings to be scoped hierarchically—for instance, distinguishing machine-wide configurations from user-specific ones—to support multi-user environments and modular organization.[2] This design facilitates logical grouping, such as by hardware, software components, or user profiles, promoting scalability as systems grow more complex.[15] To accommodate diverse configuration requirements, the Registry supports multiple data types, including strings for textual values, binary for raw data, and DWORD for 32-bit integers, enabling precise storage and retrieval without the constraints of plain-text formats. Emphasis was placed on portability through hive files that can be backed up, restored, or loaded remotely; security via access control lists (ACLs) on keys to enforce permissions in shared scenarios; and extensibility to abstract hardware details and streamline software installations by dynamically registering components.[16] Early design acknowledged trade-offs, including heightened complexity to achieve robustness in multi-user and networked settings, where the centralized model enhances consistency but requires careful protection against corruption or unauthorized access.[15]Core Structure
Keys and Subkeys
The Windows Registry employs a hierarchical structure composed of keys and subkeys, which act as named containers for organizing configuration data in a tree-like format originating from root keys. Keys serve as the primary organizational units, analogous to directories in a file system, where subkeys can be nested indefinitely within parent keys to form branches that logically group related settings. This design facilitates efficient navigation and management of system and application configurations.[2][17] Subkeys enable the subdivision of broader categories into more specific ones; for example, application settings are typically housed under subkeys within the Software branch to maintain separation by vendor or program. Key names are case-insensitive, limited to 255 characters per name, and composed of printable characters excluding the backslash (), which is reserved exclusively as the delimiter in registry paths. Paths such as HKLM\Software[Microsoft](/page/Microsoft) illustrate this hierarchy, with each segment representing a successive level of nesting.[2][18] To ensure stability and performance, the registry imposes structural limits, including a maximum depth of 512 nested levels in modern Windows versions like Windows 11, beyond which deeper nesting is not supported. These constraints, along with the overall path length cap of 32,767 characters, balance flexibility with practical bounds on complexity.[18]Registry Values
Registry values are the data entries stored within registry keys, functioning as key-value pairs where each value has a unique name relative to its parent key and holds the actual configuration data.[https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types] The name identifies the value within the key, while the data can vary in type and format to accommodate different kinds of information, such as text strings, numerical flags, or binary configurations.[https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types] Every key can contain multiple values, but value names must be unique per key, with an optional unnamed value represented as "(Default)" that serves as the key's primary or default data entry.[https://learn.microsoft.com/en-us/windows/win32/wmisdk/accessing-an-unnamed-registry-value] Windows supports a variety of predefined data types for registry values to ensure compatibility and efficient storage across applications and system components.[https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types] These types dictate how the data is interpreted and stored, with common uses including paths to files (as strings), enable/disable flags (as integers), and lists of settings (as multi-strings).[https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/windows-registry-advanced-users] For instance, a REG_DWORD value might store a binary flag to toggle a feature on or off, while a REG_BINARY value could hold raw hardware configuration bytes.[https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-value-types] The following table summarizes the supported registry value types, their formats, and typical purposes:| Type | Format Description | Typical Purpose |
|---|---|---|
| REG_BINARY | Raw binary data as a sequence of bytes. | Storing non-textual data like images, hardware IDs, or serialized structures. |
| REG_DWORD | 32-bit unsigned integer (little-endian). | Configuration flags, counters, or small numerical settings (e.g., enabling a service). |
| REG_DWORD_BIG_ENDIAN | 32-bit unsigned integer (big-endian). | Legacy compatibility for big-endian systems or specific protocols. |
| REG_DWORD_LITTLE_ENDIAN | 32-bit unsigned integer (little-endian, synonymous with REG_DWORD). | Equivalent to REG_DWORD for explicit little-endian specification. |
| REG_EXPAND_SZ | Null-terminated Unicode string containing environment variable references (e.g., %PATH%). | Paths or settings that expand dynamically using system variables. |
| REG_LINK | Unicode string representing a symbolic link to another registry key. | Creating shortcuts or references to remote keys for modular configuration. |
| REG_MULTI_SZ | Array of null-terminated Unicode strings, terminated by an empty string. | Lists of items, such as installed fonts or multiple paths. |
| REG_NONE | Data with no predefined type (rarely used). | Custom or undefined data storage without type enforcement. |
| REG_QWORD | 64-bit unsigned integer (little-endian). | Large numerical values, like file sizes or timestamps in modern applications. |
| REG_QWORD_LITTLE_ENDIAN | 64-bit unsigned integer (little-endian, synonymous with REG_QWORD). | Equivalent to REG_QWORD for explicit little-endian specification. |
| REG_RESOURCE_LIST | Binary data representing a device-driver resource list. | Hardware resource allocations for drivers (e.g., IRQ or memory ranges). |
| REG_FULL_RESOURCE_DESCRIPTOR | Binary data for a full device-driver resource descriptor. | Detailed hardware resource mappings in driver configurations. |
| REG_RESOURCE_REQUIREMENTS_LIST | Binary data for possible device-driver resource requirements. | Lists of acceptable hardware resources for flexible driver loading. |
| REG_SZ | Null-terminated Unicode string. | Simple text data, such as file paths, names, or descriptive settings. |
Root Keys
HKEY_LOCAL_MACHINE
HKEY_LOCAL_MACHINE (HKLM) is a root key in the Windows Registry that stores configuration data specific to the local computer, applicable to all users and persistent across system reboots. It contains machine-wide settings for hardware, software installations, security policies, and system services, ensuring consistent operation regardless of the logged-in user. This key is essential for maintaining the integrity of the operating system's core functions, with its data loaded into memory during the boot process to initialize the system environment.[2] The primary subkeys under HKLM include SAM, SECURITY, SOFTWARE, SYSTEM, and HARDWARE. The SAM subkey manages security account information, such as user credentials and group memberships, accessible only to administrators. SECURITY holds audit policies and other security-related configurations, also requiring elevated privileges for access. SOFTWARE stores details about installed applications, including their settings and components, while SYSTEM contains configurations for hardware components, device drivers, and services. In contrast, HARDWARE provides a dynamic, non-persistent description of the current hardware configuration, such as device mappings and resources, which is regenerated each time the system boots rather than stored permanently.[2] During the boot process, HKLM plays a critical role in system initialization, with its hives loaded early by the operating system kernel to configure hardware and load drivers. The SYSTEM subkey, in particular, defines multiple control sets—copies of hardware and service configurations—and the CurrentControlSet points to the active set used for startup, enabling the boot loader to load essential drivers with Start values like 0x0 for boot-critical components. This ensures reliable hardware detection and service activation from the outset.[5][19][20] HKLM's data persists through dedicated hive files located in the %SystemRoot%\System32\Config directory, including SYSTEM (with backups like System.alt and System.sav), SOFTWARE, SAM, and SECURITY, each accompanied by log files for transaction recovery. These hives are loaded into memory upon OS startup, supporting ongoing system operations. Specific uses of HKLM include storing licensing information for Windows and applications under SOFTWARE\Microsoft, configuring hardware abstraction layers (HAL) via the SYSTEM subkey for low-level hardware interactions, and maintaining the current control set for active system configurations.[5][21] In Windows 11, HKLM has been enhanced to better integrate with security features like Secure Boot and Trusted Platform Module (TPM) 2.0, with dedicated registry paths under SYSTEM\CurrentControlSet\Control\SecureBoot for managing boot states and PCR bank selections in TPM devices, ensuring cryptographic keys are available only during verified boot phases.[22]HKEY_CURRENT_USER
HKEY_CURRENT_USER (often abbreviated as HKCU) is a predefined root key in the Windows Registry that stores configuration settings specific to the currently logged-in user, including preferences for the desktop environment, installed applications, and system behaviors tailored to individual user profiles.[3] This key ensures that user-specific customizations, such as display themes or application defaults, persist across sessions without affecting other users or the system's core hardware configurations.[3] It serves as a dynamic alias, redirecting to the relevant subkey within the broader HKEY_USERS structure to facilitate seamless access during user interactions.[7] HKCU is derived from the HKEY_USERS<SID> subkey, whereHKEY_CLASSES_ROOT
HKEY_CLASSES_ROOT (HKCR) serves as a virtual registry hive that provides a merged view of file associations, Component Object Model (COM) class registrations, and shell extensions, enabling applications to interact with files and system objects in a standardized manner. This key combines data from HKEY_LOCAL_MACHINE\Software\Classes, which contains machine-wide settings, and HKEY_CURRENT_USER\Software\Classes, which holds user-specific overrides, with the latter taking precedence where duplicates exist.[29] The merging process ensures that user preferences, such as custom file handlers, supersede system defaults without altering the underlying machine configurations.[29] This structure allows HKCR to act as a unified interface for the Windows shell and applications to query and apply associations dynamically. The core structure of HKCR organizes file associations through subkeys named after file extensions, such as .txt or .docx, where each extension subkey typically points to a programmatic identifier (ProgID) via its default value. For instance, the .txt subkey might link to the txtfile ProgID, under which further subkeys define actions like opening the file with a specific program through paths such as shell\open\command.[30] ProgIDs serve as human-readable aliases for more complex class definitions, facilitating the mapping of file types to appropriate handlers and ensuring consistent behavior across the system. In addition to file extensions, HKCR includes subkeys like CLSID for COM registrations, where each class identifier (CLSID)—a 128-bit globally unique identifier—registers COM class objects used in Object Linking and Embedding (OLE).[31] These CLSID entries often include subkeys for in-process servers (InprocServer32) and interface definitions (Interface), enabling components to be instantiated and interacted with across processes.[32] HKCR also plays a pivotal role in defining shell behaviors, including context menu verbs and the shell namespace. Verbs are registered under ProgID\shell\verb subkeys, where each verb (e.g., "open" or "print") specifies commands that appear in shortcut menus when users right-click files, allowing actions like launching applications or performing operations via COM interfaces.[33] For the shell namespace, HKCR integrates virtual folders through CLSID-based definitions; for example, the "My Computer" (now "This PC") folder is represented by the CLSID {20D04FE0-3AEA-1069-A2D8-08002B30309D}, enabling the shell to treat non-physical data sources as navigable directories within Windows Explorer.[34] This namespace extension mechanism allows developers to extend the file system view with custom virtual items, such as network drives or control panel applets, all rooted in HKCR's hierarchical structure. In modern Windows versions like Windows 10 and 11, HKCR has seen partial migration for Universal Windows Platform (UWP) apps, where file associations and protocol handlers are primarily declared in the app's AppxManifest.xml rather than direct registry writes.[35] These declarations result in system-managed registrations under keys like HKEY_CURRENT_USER\Software\Classes\Extensions\ContractId, integrating UWP apps into the HKCR view without traditional ProgID setups, thus maintaining compatibility while leveraging package-based deployment for security and isolation.[36] This evolution reduces direct registry modifications by UWP apps, shifting toward declarative packaging to handle associations more robustly in sandboxed environments.HKEY_USERS
HKEY_USERS, often abbreviated as HKU, serves as the primary registry root key for storing configuration data from all actively loaded user profiles on a Windows system.[7] It acts as a container where individual user hives are mounted dynamically upon user logon, enabling multi-user environments to maintain separate settings without interference. Unlike system-wide configurations, this key focuses exclusively on per-user data, ensuring isolation for preferences, application states, and environment variables across concurrent sessions.[5] The structure of HKEY_USERS consists of subkeys named after each user's Security Identifier (SID), such as S-1-5-21-... for local or domain accounts, representing the unique identifier assigned to the user or group.[37] Additionally, it includes a special subkey named .DEFAULT, which loads the default user hive from the system's template profile (typically sourced from %SystemRoot%\System32\config\DEFAULT), serving as the baseline for new user profiles created during initial logons.[38] These SID-based subkeys mirror the full contents of a user's NTUSER.DAT hive file, encompassing major branches like Software for application-specific settings and Network for mapped drives and connectivity preferences.[5] Upon user logon, the corresponding SID subkey is loaded into HKEY_USERS, allowing multiple SIDs to coexist in scenarios such as Fast User Switching in Windows XP and later or Remote Desktop Services (formerly Terminal Services) in multi-session environments.[39] This supports simultaneous access for several users, with each profile remaining active until logoff or system shutdown. In enterprise settings, administrators leverage HKEY_USERS for SID resolution to manage domain user configurations, using tools like WMI queries to map SIDs to usernames for targeted policy application or auditing across Active Directory-integrated systems.[40] HKEY_CURRENT_USER provides a convenient alias to the active user's specific SID subkey within HKEY_USERS, simplifying access for running processes without needing to specify the full path.[7]HKEY_CURRENT_CONFIG
HKEY_CURRENT_CONFIG (HKCC) is a predefined registry root key that represents the active hardware profile for the local computer system. It functions as a dynamic alias to the path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\Current, providing a convenient view of profile-specific settings without duplicating the entire system configuration.[3] This structure allows applications and system components to query hardware adaptations tailored to the current environment, such as varying device states on portable systems. The key primarily stores differences between the active hardware profile and the baseline system configuration stored in HKEY_LOCAL_MACHINE, enabling targeted overrides for elements like display resolutions or peripheral device behaviors.[3] For instance, in scenarios involving docking stations versus standalone laptop operation, HKCC may hold adjusted configurations for graphics adapters or connected peripherals to ensure optimal functionality without altering global settings. These profile-specific details facilitate seamless transitions during hardware changes detected at runtime. As a volatile construct, HKEY_CURRENT_CONFIG is regenerated each time the system boots, with its content dynamically resolved based on the hardware profile selected by the boot loader through automated detection of connected devices and system state.[3] This non-persistent nature means it does not rely on dedicated hive files for storage; instead, it reflects real-time mappings that are discarded and rebuilt on subsequent startups, promoting efficiency in transient configurations. Under HKCC, the subkey System\CurrentControlSet mirrors relevant portions of its counterpart in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet but includes only the overridden values pertinent to the current profile, avoiding unnecessary replication of unchanged settings.[3] This selective copying ensures that the system loads customized parameters—such as driver paths or resource allocations—while inheriting defaults from the base hive. In contemporary Windows implementations, including Windows 11, the utility of HKEY_CURRENT_CONFIG is significantly diminished, as hardware profiles have been deprecated in favor of advanced Plug and Play mechanisms and unified device management frameworks that handle dynamic configurations more robustly.[41]HKEY_PERFORMANCE_DATA
HKEY_PERFORMANCE_DATA serves as a virtual root key in the Windows Registry, providing a dynamic interface for accessing real-time system performance data without persistent storage. Unlike standard registry hives, this key does not maintain data on disk; instead, it generates performance counter information on demand through the registry API when queried.[42] The performance subsystem, managed by components such as the Performance Library (PerfLib), handles this generation by aggregating data from kernel drivers, system services, and third-party providers.[43] This design enables efficient, low-overhead retrieval of metrics for monitoring tools, distinguishing it from static registry keys used for configuration. The structure under HKEY_PERFORMANCE_DATA is organized into subkeys representing performance objects or categories, such as Processor for CPU utilization metrics or Memory for RAM allocation details. Each subkey contains binary value entries that encapsulate raw performance data in a structured format, including counter values, instances (e.g., per-core processor data), and timestamps. For instance, querying the "Processor" subkey might return binary blobs detailing "% Processor Time" across logical processors. Applications access this data via Windows API functions like RegQueryValueEx, specifying the HKEY_PERFORMANCE_DATA handle and a subkey path as the value name; the function triggers the subsystem to compute and return the current counter values without modifying the registry. Tools like Performance Monitor leverage this interface indirectly through higher-level APIs such as the Performance Data Helper (PDH) library, which builds on the registry functions for graphing and logging.[42][44][45] Introduced as a predefined key in Windows NT 3.1 to support the initial Performance Monitor tool, HKEY_PERFORMANCE_DATA has evolved to accommodate both legacy Version 1 (V1) and modern Version 2 (V2) performance counter providers, with enhancements in Windows 10 including expanded support for telemetry-related diagnostics through integrated counter sets.[3][43] This evolution replaced earlier dynamic mechanisms like HKEY_DYN_DATA, which was limited to Windows 9x/Me systems. Access to HKEY_PERFORMANCE_DATA is restricted to members of the Administrators or Performance Monitor Users group to prevent unauthorized monitoring of sensitive system metrics, ensuring it remains a tool for diagnostics rather than user configuration or modification.[46][47]Hives and Storage
Hive Architecture
The Windows Registry is organized into logical units known as hives, which are self-contained subtrees consisting of keys, subkeys, and values that can be independently loaded and managed. Each hive serves as a discrete portion of the overall registry structure, with a designated root key that anchors its hierarchy; for instance, the SYSTEM hive encompasses the HKLM\SYSTEM subtree, storing configuration data for hardware and system services. This modular design allows the operating system to handle registry data efficiently by isolating components related to specific functions, such as user profiles or system settings.[5][48] Hives are loaded into memory during system initialization or user sessions through a structured process managed by core system components. At boot, the configuration manager, operating within the Session Manager subsystem (SMSS.EXE), mounts the primary system hives—including those for HKLM\SYSTEM, HKLM\SOFTWARE, HKLM\SAM, and HKLM\SECURITY—drawing from predefined configuration to establish the foundational registry state. User-specific hives, such as those mapping to HKEY_CURRENT_USER, are subsequently loaded upon logon to integrate profile data without affecting the global structure. This phased loading ensures that only essential data is available early in the boot sequence, supporting rapid system startup.[49][5] To optimize memory usage, the registry employs lazy loading, where subhives—smaller subdivisions within a parent hive—are not fully loaded into memory until explicitly accessed by an application or service. This on-demand mechanism reduces initial resource overhead, as the kernel only allocates memory for registry portions required during runtime operations, such as querying a specific key. Subhives can be dynamically mounted or unloaded as needed, maintaining performance while accommodating the registry's expansive size.[11] The registry maintains a distinction between core system hives and user-specific ones for targeted management. Core hives include DEFAULT (providing a template for new user profiles), SAM (managing security accounts), SECURITY (handling access policies), SOFTWARE (storing application configurations), and SYSTEM (configuring drivers and services). In contrast, user hives are per-profile files like NTUSER.DAT, which load personalized settings under HKEY_CURRENT_USER for each logged-in user, enabling isolation of individual configurations.[5][50] For data integrity, particularly in Windows Vista and later versions, hives incorporate checksums within their binary structure to detect corruption during reads or writes, verifying the consistency of data blocks known as bins. Additionally, transaction logs serve as journals recording pending changes before they are committed to the hive, enabling atomic updates via the Kernel Transaction Manager and facilitating recovery from crashes or power failures by replaying or rolling back operations. These features ensure that incomplete writes do not leave the registry in an inconsistent state, enhancing reliability for critical system data.[51][52]File Locations Across Versions
The physical storage of the Windows Registry has evolved significantly from its predecessors in early versions to a structured binary format in modern editions, reflecting changes in operating system architecture, security, and portability requirements. In Windows 3.1, the Registry's conceptual precursor consisted of text-based initialization (INI) files that stored system and application configurations. The primary files, WIN.INI and SYSTEM.INI, were located in the Windows installation directory (typically C:\Windows), alongside numerous application-specific INI files in the same directory for settings like fonts, drivers, and user preferences.[7] Windows 95 and 98 marked the introduction of the binary Registry format, stored in two primary hidden, read-only files: System.dat (containing HKEY_LOCAL_MACHINE and HKEY_CURRENT_CONFIG data) and User.dat (for HKEY_CURRENT_USER and HKEY_CLASSES_ROOT user-specific settings), both located in the root Windows directory (C:\Windows). Windows Millennium Edition (ME) expanded this to three files by adding Classes.dat for HKEY_CLASSES_ROOT class registrations, while retaining System.dat and User.dat in the same location. Additional hidden files supported specialized functions, including Config.dat for hardware profile configurations and security-related files such as Secur95.dat (in Windows 95) or similar masked files like Secu*.dat for access controls, all within C:\Windows to maintain backward compatibility with DOS-based systems. Backup copies, such as System.da0 and User.da0, were automatically generated by tools like ScanReg.exe.[7] Starting with Windows NT 4.0 and continuing unchanged through Windows 2000, XP, Vista, 7, 8, 10, and 11, the Registry hives for machine-wide settings (under HKEY_LOCAL_MACHINE, excluding user data) are stored as binary files in the %SystemRoot%\System32\config directory, typically C:\Windows\System32\config. Key files include:| Hive | Primary File | Backup Files |
|---|---|---|
| HKEY_LOCAL_MACHINE\SAM | SAM | SAM.log, SAM.sav |
| HKEY_LOCAL_MACHINE\SECURITY | SECURITY | SECURITY.log, SECURITY.sav |
| HKEY_LOCAL_MACHINE\SOFTWARE | SOFTWARE | SOFTWARE.log, SOFTWARE.sav |
| HKEY_LOCAL_MACHINE\SYSTEM | SYSTEM | SYSTEM.log, SYSTEM.sav, SYSTEM.alt |
Editing Methods
Graphical Editors
The primary graphical tool for viewing and modifying the Windows Registry is Regedit.exe, a built-in editor that presents the registry in a hierarchical tree view, allowing users to navigate keys, subkeys, values, and data types interactively.[7] Introduced with Windows 95, Regedit.exe was later ported to Windows NT 4.0 to provide a more user-friendly alternative to the existing editor, enabling features like full-text search across the registry (via Ctrl+F), import and export of .reg files for subkeys and values, and remote registry editing on Windows NT-based systems.[10][56] Prior to Windows XP, Windows NT-based systems also included Regedt32.exe as a legacy editor, which supported multi-window views for simultaneous editing of different hives and provided advanced access control list (ACL) modifications for security permissions on keys and values.[57] Starting with Windows XP, Regedt32.exe was deprecated and merged into Regedit.exe, with the former becoming a lightweight stub that launches the latter; modern versions of Regedit.exe thus incorporate both single-pane tree navigation and multi-select capabilities for permissions viewing and editing.[1] Additional features in Regedit.exe include a favorites list for quick access to frequently used keys (added in Windows 2000) and the ability to view and modify security descriptors on registry objects, including changing ownership of keys and subkeys and granting full control to groups such as Administrators via the Advanced Security Settings dialog, aiding administrators in managing permissions without external tools.[58][59] Third-party graphical editors extend Regedit.exe's functionality with enhancements like faster searches, drag-and-drop operations, and registry defragmentation. For example, Total Registry (formerly known as Registry Explorer), developed by Windows internals expert Pavel Yosifovich, offers a modern interface with virtual hive support, advanced filtering, and visualization of symbolic links, making it suitable for forensic analysis and complex navigation.[60] Tools like CCleaner's registry module provide built-in search and cleanup features alongside defragmentation to optimize hive file sizes, though users should exercise caution as automated modifications can introduce instability if not verified. On 64-bit Windows systems, Regedit.exe operates under WOW64 (Windows-on-Windows 64-bit) redirection, where the 32-bit version (located in SysWOW64) automatically routes accesses to a separate registry view under keys like HKEY_LOCAL_MACHINE\Software\WOW6432Node, isolating 32-bit application data from 64-bit entries.[61] To access the native 64-bit view, administrators must run the 64-bit Regedit.exe from System32, ensuring compatibility when editing architecture-specific configurations; failure to do so can lead to unintended modifications in the wrong view.[62]Text-based Editing
Text-based editing of the Windows Registry involves using plain text files with the .reg extension to import or export registry keys, subkeys, and values in a batch manner. These files allow administrators and software developers to apply changes without interactive graphical tools, facilitating automated or remote modifications across multiple systems. The .reg format supports both ANSI and Unicode encodings, with the choice determining compatibility and the header line used.[63] The .reg file begins with a header identifying the version and encoding: "REGEDIT4" for ANSI format, compatible with Windows 9x and NT 4.0, or "Windows Registry Editor Version 5.00" for Unicode (UTF-16 LE with byte-order mark), used in Windows 2000 and later versions. Following the header, sections denote registry paths enclosed in square brackets, such as [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]. Value entries within sections follow the syntax "ValueName"=type:value, where the type specifies the data format— for example, a string value as "Installed"="1", a DWORD as "MaxConnections"=dword:00000014, or binary data as "Data"=hex:01,00,00,00 using hexadecimal notation. Multi-line values like expandable strings or multi-strings employ hex(2): or hex(7): prefixes with comma-separated bytes and null terminators. String values containing spaces or special characters require double quotes, and binary data uses the hex() wrapper to distinguish it from other types; paths must not end with trailing backslashes unless specifying a subkey.[56][63] .reg files can be created by exporting selected registry branches from Regedit.exe, which generates the file in the appropriate format, or by manually editing text in a tool like Notepad and saving with the .reg extension. To apply changes, users double-click the file, prompting a confirmation dialog before merging the contents into the live registry; this process validates syntax and reports errors if malformed. For unattended operations, the /s switch enables silent import via command line, as in regedit /s example.reg, suppressing prompts and suitable for scripts or deployment.[56] Common use cases include software installers that bundle .reg files to register components or set defaults, and system administrators applying tweaks like disabling telemetry or configuring services across enterprise environments. For deletions in Windows 2000 and later, a minus sign prefixes the target, such as [-HKEY_LOCAL_MACHINE\Software\Example] to remove a subkey or "UnwantedValue"=- to delete a value, enabling complete cleanup operations. However, .reg files prior to Windows 2000 lack this deletion syntax, limiting them to additions and modifications only, and all imports undergo validation to prevent invalid data from corrupting the registry.[56]Command-line Tools
The primary command-line tool for manipulating the Windows Registry is Reg.exe, a console utility that enables administrators to add, delete, query, copy, compare, export, and import registry subkeys and values on local or remote computers.[64] This tool provides a text-based interface for direct Registry operations without requiring a graphical editor, making it suitable for scripting, automation, and remote administration tasks.[7] Reg.exe has been available since the Windows 2000 release via the support tools on the installation media, becoming a built-in component starting with Windows XP.[65] It supports operations on remote machines using the/machine parameter, though some functions like export and import have limitations when targeting remote systems due to file access restrictions.[64]
Key commands include:
- add: Creates a new subkey or adds a value to an existing subkey. For example, to add a string value to the local machine:
This command specifies the registry path (reg add HKLM\Software\Example /v ExampleValue /t REG_SZ /d "Example Data"HKLM\Software\Example), value name (ExampleValue), type (REG_SZfor string), and data.[66] - delete: Removes a subkey or value. Syntax:
reg delete <key> [/v <value>] [/f], where/fforces deletion without prompting. - query: Displays subkeys and values under a specified key. Example:
reg query HKLM\Software /slists all subkeys and values recursively (/sflag). - copy: Duplicates a key or value to another location. Syntax:
reg copy <source> <destination> [/s] [/f]. - compare: Compares two keys or values, highlighting differences. Example:
reg compare HKLM\Software\A HKLM\Software\Boutputs identical, different, or extra entries. - export: Saves a key's contents to a .reg file. Syntax:
reg export <key> <filename> [/y], where/ysuppresses the overwrite prompt. - import: Loads data from a .reg file into the Registry. Example:
reg [import](/page/Import) backup.reg.
/ve flag in query operations to show full value data, aiding in detailed inspection and troubleshooting.
While Reg.exe handles core Registry operations, alternatives like the WMI Command-line tool (Wmic.exe) offer additional methods for querying and modifying Registry data via WMI classes, such as wmic /namespace:\\root\default path StdRegProv getstringvalue.[7] For more advanced scripting, PowerShell cmdlets like Get-ItemProperty extend command-line capabilities but are typically covered in automation contexts.
Scripting and Automation
The Windows Registry supports extensive scripting and automation capabilities, enabling administrators and developers to manage keys, values, and hives programmatically across local, remote, and offline scenarios. This is primarily achieved through built-in tools like PowerShell, which provides object-oriented cmdlets for querying and modifying the registry in a structured manner, and APIs such as WMI and COM for more integrated or distributed access. Offline editing tools allow mounting and editing hives from external installations, while .NET frameworks offer transactional support for robust automation in applications. These methods facilitate tasks like deployment scripting, configuration management, and troubleshooting without relying on graphical interfaces. PowerShell cmdlets form a core part of registry automation, treating the registry as a navigable file system via theHKLM:, HKCU:, and similar PSDrives. For instance, Get-ItemProperty retrieves values from a specified path, such as Get-ItemProperty -Path HKLM:\Software\Microsoft\Windows\CurrentVersion to fetch product name and version details. Similarly, Set-ItemProperty updates values, like setting a DWORD entry with -Name "ExampleKey" -Value 1 -Type DWord, while New-Item creates new keys or subkeys, ensuring atomic operations within scripts. These cmdlets support piping for chained operations, error handling via try-catch blocks, and remote execution through Invoke-Command, making them ideal for enterprise automation.
For remote and offline edits, Windows Management Instrumentation (WMI) and Component Object Model (COM) APIs provide deeper integration, particularly in distributed environments. The Win32_Registry WMI class allows querying and modifying registry keys on remote machines via methods like GetStringValue and SetStringValue, requiring appropriate DCOM permissions and often used in scripts with tools like wbemtest.exe or PowerShell's Get-WmiObject. COM interfaces, such as those exposed by IRegistry objects, enable programmatic access from languages like VBScript or C++, supporting offline scenarios by connecting to loaded hives. These APIs are essential for system management tasks, such as applying configurations across a network without physical access.
Offline editing of registry hives is facilitated by the reg load and reg unload operations, which mount hives from external files or another OS installation into the live registry for scripting access. For example, a script can load the SYSTEM hive from an offline Windows image using reg load HKLM\Temp C:\Windows\System32\config\SYSTEM, perform modifications via PowerShell or APIs, and then unload it with reg unload HKLM\Temp to avoid corruption. This technique is commonly used in deployment tools like Windows PE for repairing or customizing installations, with safeguards like taking hive backups beforehand. Basic command-line tools like reg.exe can invoke these in scripts, though they are often wrapped in batch or PowerShell for automation.
COM self-registration automates registry updates during software installation by invoking functions like DllRegisterServer in a DLL, which adds necessary keys under HKEY_CLASSES_ROOT for component activation. This process, typically called via rundll32.exe or setup scripts, registers ProgIDs, CLSIDs, and interfaces without manual editing, ensuring compatibility in automated deployment pipelines. Developers implement this by exporting the function in their DLL, which Windows calls to write self-describing entries for COM objects.
Advanced automation in .NET applications leverages the Microsoft.Win32.Registry class for transactional edits, allowing safe, rollback-capable modifications to keys and values. Methods like RegistryKey.CreateSubKey and SetValue support opening hives with Registry.LocalMachine or Registry.Users, while the using statement ensures disposal and transaction integrity via Transaction objects in newer frameworks. This is particularly useful for line-of-business applications requiring persistent, error-resilient configuration changes.
Security Features
Access Control Mechanisms
The Windows Registry employs access control lists (ACLs) to manage security for its keys and values, ensuring that only authorized users or processes can perform operations. Each registry key has an associated security descriptor that includes a discretionary access control list (DACL) and a system access control list (SACL), both composed of access control entries (ACEs). These ACEs identify trustees—represented by security identifiers (SIDs), such as the Administrators group or the SYSTEM account—and specify the access rights granted or denied, along with inheritance flags that determine if permissions propagate to subkeys.[68][16][69] The DACL governs access permissions, explicitly allowing or denying operations on registry objects. Standard permissions include KEY_QUERY_VALUE for reading value names and data, KEY_SET_VALUE for writing or modifying values, KEY_CREATE_SUB_KEY for creating subkeys, and KEY_DELETE for removing subkeys or values; these can be combined into broader sets like KEY_READ (encompassing query, enumeration, and notification rights) or KEY_WRITE (including set value, create subkey, and delete rights). Permissions are either explicitly defined on a key or inherited from its parent, with object-specific ACEs overriding inheritance for particular trustees, thereby providing granular control over registry access.[16][70][71] Ownership of registry keys is typically assigned to high-privilege accounts to prevent unauthorized modifications, with the SYSTEM account owning many system-level keys and the TrustedInstaller account (associated with the Windows Modules Installer service) securing protected areas like those under HKEY_LOCAL_MACHINE\SOFTWARE[Microsoft](/page/Microsoft)\Windows. Owners can modify the DACL and take ownership of subkeys but cannot inherently access keys owned by higher-privilege entities without elevation. To change ownership, administrators can use tools like the SubInACL utility from the Windows Resource Kit or PowerShell cmdlets such as Set-Acl, though Regini.exe is primarily for setting permissions rather than ownership transfers.[71][72] Auditing in the Registry is facilitated through the SACL, which specifies which access attempts—successful or failed—should generate security events for trustees like unauthorized users attempting reads or writes. When auditing is enabled on a key's SACL, events such as ID 4656 (handle requests), 4657 (value modifications), or 4663 (object access attempts) are logged in the Windows Security event log, viewable via Event Viewer, allowing administrators to monitor and investigate potential security incidents. Global object access auditing can apply SACLs across the entire registry for centralized monitoring.[16][73][74] User Account Control (UAC), introduced in Windows Vista and later versions, integrates with Registry access by requiring elevation prompts for operations on protected keys, such as writing to HKEY_LOCAL_MACHINE hives, even for members of the Administrators group running in a filtered standard user token. This mechanism ensures that administrative privileges are not exercised without explicit consent, reducing the risk of malware or erroneous changes to critical system settings.[75][76]Common Vulnerabilities
One prevalent vulnerability in the Windows Registry involves malware injection, where trojans and worms exploit autorun keys to achieve persistence and automatic execution upon system startup. For instance, threats like Worm:Win32/Autorun.OA modify entries under the HKLM\SOFTWARE[Microsoft](/page/Microsoft)\Windows\CurrentVersion\Run subkey to drop copies of themselves and propagate across fixed and removable drives.[77] Similarly, fileless malware can encode malicious scripts directly into these autorun registry keys via command-line execution, evading traditional detection by residing solely in memory and registry structures.[78] Privilege escalation represents another critical risk, stemming from weak access control lists (ACLs) on registry keys that permit non-administrative users to alter system-critical entries. Attackers can exploit misconfigured ACLs on service-related keys, such as those under HKLM\SYSTEM\CurrentControlSet\Services, to modify the ImagePath value and redirect execution to malicious payloads, thereby elevating privileges to SYSTEM level.[79] This issue arises from improper permission inheritance or manual overrides, allowing local users to hijack legitimate services without administrative rights. Exploits targeting .REG files have been documented since 2019, affecting versions including Windows 7, 8.1, and 10. These files, used for importing registry modifications, could be crafted to spoof confirmation dialogs during import, tricking users into applying malicious changes without awareness—such as altering security settings or injecting code—due to insufficient input sanitization.[80] While Microsoft introduced improvements in Windows 10 for stricter parsing and user prompts, bypass techniques for such dialog spoofing were reported as late as 2022. No new public exploits of this type have been disclosed as of November 2025.[81] Specific attacks further compound these threats, including registry reflection techniques that leverage the 32-bit/64-bit registry redirector (e.g., via Wow6432Node) for code execution by injecting payloads that exploit discrepancies in key mappings between architectures. Additionally, hive corruption via physical access enables attackers with device possession to directly edit or damage offline hive files like SYSTEM or SOFTWARE in the %SystemRoot%\System32\config directory, leading to system instability or backdoor implantation upon reboot.[82][83] To mitigate these vulnerabilities, organizations can deploy AppLocker to enforce whitelisting of executable files and scripts, preventing unauthorized modifications to autorun keys or service entries by blocking non-approved binaries from running.[84] Starting with Windows 10 version 1709 and later, including Windows 11, Windows Defender Application Control (WDAC) applies kernel-level policies that restrict code execution based on publisher signatures and file paths, effectively blocking malware injections and privilege escalations at the registry level.[85] Complementing these, regular scans using the Microsoft Sysinternals Autoruns tool help detect anomalous entries in autorun locations and persistence mechanisms, allowing administrators to identify and remove threats proactively.Backup and Recovery
Built-in Backup Tools
Windows provides several built-in tools for creating backups of the Registry, enabling users to capture snapshots of configuration data for recovery purposes. The Registry Editor (Regedit.exe), a graphical interface available since early Windows versions, allows users to export the entire Registry or specific branches to a .REG file, which stores keys, subkeys, entries, and values in a text-based format for easy transfer or restoration.[86] To perform an export, users launch Regedit, select the desired root or subkey, and choose File > Export, specifying a save location and filename with the .REG extension.[86] This method supports selective backups, such as individual hives like HKEY_LOCAL_MACHINE, making it suitable for targeted configuration preservation.[87] In Windows 10 and 11, users can enable automatic periodic backups of the Registry by creating a DWORD value named EnablePeriodicBackup set to 1 under the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Configuration Manager. This feature, inherited from earlier Windows versions, generates backups of system hives in the %SystemRoot%\System32\config\RegBack folder during system idle times, providing proactive protection without manual intervention (as of January 2025).[88] System Restore, integrated into Windows since Windows Me and enhanced in later versions, automatically creates restore points that include Registry snapshots alongside system files and installed programs.[89] When a restore point is generated—either manually via the System Protection settings or automatically before significant events like driver installations—Windows captures the state of the Registry at that moment, allowing reversion to a previous configuration without affecting personal files.[89] These points are stored in the System Volume Information folder and can be managed through the System Restore interface in the Control Panel or Settings app.[90] For server environments, the WBAdmin command-line tool, introduced in Windows Server 2008, facilitates system state backups that encompass the Registry hives as part of critical system components.[7] Thewbadmin start systemstatebackup command creates a backup of the system state—including boot files, the Registry, and COM+ database—to a specified location, such as a local drive or network share, without including user-specific hives like HKEY_CURRENT_USER.[91] Administrators can schedule these backups or run them on demand, requiring elevated privileges and the Windows Server Backup feature to be installed.[91] This approach ensures comprehensive protection for system-level Registry data in enterprise settings.[7]
The Volume Shadow Copy Service (VSS), a core Windows component since Windows XP, enables automatic backups of Registry files through shadow copies, particularly useful for configuration data in active systems.[92] VSS coordinates with the Registry Writer to create point-in-time snapshots of the hives (e.g., SYSTEM, SOFTWARE) by exporting active files during backup operations, ensuring consistency even while the system is running.[92] This service integrates with tools like File History or previous versions in Explorer, allowing users to access shadowed Registry versions indirectly via file recovery, though direct Registry restoration from VSS requires compatible backup applications.[93]
In Windows 11, the Settings app introduces cloud-based backups for user-specific configurations via a Microsoft Account, syncing select Registry-stored settings across devices.[94] Accessible under Accounts > Windows Backup, this feature captures elements like accessibility options, language preferences, wallpapers, Wi-Fi credentials, and installed apps—many of which reside in the HKEY_CURRENT_USER hive—and stores them in OneDrive for seamless restoration on new PCs.[94] It requires signing in with a Microsoft Account and focuses on user profiles rather than system-wide hives.[95]
These built-in tools have limitations, including the absence of incremental backups, which means each operation captures the full state anew, potentially consuming significant time and storage.[86] Full Registry exports via Regedit, for instance, can result in .REG files hundreds of megabytes in size on typical installations, depending on accumulated configurations and software.[96] Additionally, tools like WBAdmin exclude user hives, and VSS snapshots may not support direct Registry-level restores without third-party integration, emphasizing the need for complementary recovery strategies.[91]
Recovery Procedures
Recovery procedures for the Windows Registry involve restoring from exported backups, leveraging boot options for rollback, or using diagnostic tools to address corruption without full reinstallation. These methods target the registry hives stored in %SystemRoot%\System32\Config, which can become corrupted due to improper shutdowns, malware, or failed updates.[5] Prior to recovery, ensure a recent backup exists, as created using tools like Regedit's export function or the Registry Editor's built-in features.[86] One primary method is importing .REG files, which contain exported subkeys and values. Users can double-click a .REG file in File Explorer to merge its contents into the live registry, prompting confirmation before application.[56] Alternatively, open Registry Editor (regedit.exe) as administrator, select File > Import, navigate to the .REG file, and confirm to restore the data.[86] For command-line automation, executereg import filename.reg in an elevated Command Prompt, where the file path specifies the backup; this copies subkeys, entries, and values directly into the registry.[97] These approaches are suitable for targeted restores but require the system to boot normally.
The Last Known Good Configuration boot option, available in Windows NT-based versions through Windows 7 (including Vista), allows rollback to the most recent successful control set in HKLM\SYSTEM by selecting it from the Advanced Boot Options menu (accessed via F8 during startup).[98] This loads the prior configuration, preserving hardware and driver settings from the last stable boot without affecting user data.[99] However, this feature was removed starting with Windows 8 and is unavailable in Windows 10 and 11, replaced by Startup Repair in the Windows Recovery Environment (WinRE).[100]
Booting into Safe Mode provides a minimal environment for registry repair by loading only essential hives and drivers, isolating issues from third-party software. Access Safe Mode via WinRE by interrupting boot three times to trigger Automatic Repair, then selecting Troubleshoot > Advanced options > Startup Settings > Restart and choosing option 4 or 5.[101] In this mode, run Regedit to manually edit or import fixes, or use command-line tools to diagnose corruption, as the reduced load prevents further damage.[102]
For offline repairs when the system fails to boot, use WinRE to load registry hives directly. Boot into WinRE via installation media or repeated power cycles, open Command Prompt from Troubleshoot > Advanced options, and launch Regedit. Select HKEY_LOCAL_MACHINE, then File > Load Hive, navigate to the offline installation's C:\Windows\System32\Config folder (adjust drive letter if needed), and select the hive file (e.g., SYSTEM or SOFTWARE); assign a temporary key name for editing.[103] After modifications, select the temporary key and choose File > Unload Hive to save changes, then exit and restart.[104] This method enables precise corrections to corrupted hives without mounting the live system.
System integrity tools assist in automated recovery. The System File Checker (SFC) command sfc /scannow, run from an elevated Command Prompt or WinRE, scans protected system files—including registry hives—for corruption and replaces them from the component store.[105] If SFC detects unrepairable issues due to a damaged store, use Deployment Image Servicing and Management (DISM) with DISM /Online /Cleanup-Image /RestoreHealth in Windows 11 to repair the underlying image, potentially restoring registry integrity indirectly by fixing boot-related components.[106] Rerun SFC afterward to verify repairs. These tools are essential for corruption stemming from file-level errors rather than logical inconsistencies.
Policy Management
Group Policy Integration
Group Policy Objects (GPOs) enable centralized management of Windows Registry settings in domain environments, allowing administrators to enforce configurations across multiple machines and users. During GPO processing, the system applies Administrative Templates, which define registry-based policies and map them to specific locations in the Registry, such as HKLM\SOFTWARE\Policies for computer-wide settings. These templates ensure that policy changes are written to protected keys that override user or application modifications, with settings intermediately stored in binary Registry.pol files located in the Group Policy machine folder before being merged into the Registry, maintaining consistency in enterprise deployments.[107][108] Administrative Templates are implemented using XML-based ADMX files, which provide metadata for policy settings and support multilingual editing in tools like the Group Policy Management Console (GPMC). For local management, the Group Policy Editor (gpedit.msc) allows configuration of these templates on standalone systems, while the Resultant Set of Policy (RSOP) utility, accessible via rsop.msc, provides a limited view of effective policies from applied GPOs (though incomplete since Windows Vista SP1, particularly for security settings); for comprehensive display of cumulative policies including Registry impacts, use the gpresult command-line tool. This integration facilitates auditing and troubleshooting of Registry modifications driven by group policies.[109][110] Group Policy differentiates between enforced policies and preferences to balance administrative control with user flexibility. Enforced policies, such as those setting password complexity requirements, create immutable Registry entries under paths like HKLM\SOFTWARE\Policies[Microsoft](/page/Microsoft) that cannot be altered by end-users or applications, ensuring compliance. In contrast, preferences apply softer configurations, like drive mappings or printer settings, to standard Registry locations without enforcement, allowing users to override them if needed.[111][111] User-specific restrictions, including limits on Control Panel access or application execution, are commonly enforced through GPOs that target the HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies subkey. For instance, settings under HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer can disable features like folder options or run dialogs, applying restrictions during user logon.[112][113] In Windows 11, integration extends to cloud-based management via Mobile Device Management (MDM) solutions like Microsoft Intune, where GPOs can trigger automatic enrollment and sync policy settings to the local Registry. This hybrid approach allows domain-joined devices to receive cloud GPOs that mirror traditional on-premises configurations, updating Registry keys for features like security baselines without requiring constant domain connectivity.[114][115]Legacy System Policies
In pre-Windows 2000 systems, legacy system policies provided a mechanism for administrators to enforce configuration settings on client machines by modifying the Windows Registry. For Windows 95 and Windows 98, these policies were managed through binary policy files named Config.pol, typically stored in the Windows directory on the local machine or in a network share for centralized administration.[116] These files were created and edited using the System Policy Editor tool, Poledit.exe, which was included in the Windows 98 Resource Kit or available on the installation CD in the Tools\Reskit\Netadmin\Poledit folder.[117] Upon application, the settings from Config.pol were written to the Registry under the key HKCU\Software\Microsoft\Windows\CurrentVersion\Policies, allowing control over user-specific behaviors such as desktop restrictions and software installations.[118] In Windows NT 4.0 environments, system policies functioned similarly but were tailored for domain-based administration, using files named NTConfig.pol stored in the root of the NETLOGON share on domain controllers.[119] The System Policy Editor (also Poledit.exe) was used to define these policies, which were applied automatically during user logon, downloading NTConfig.pol from the domain controller and updating the Registry at HKCU\Software[Microsoft](/page/Microsoft)\Windows\CurrentVersion\Policies for users or HKLM\Software[Microsoft](/page/Microsoft)\Windows\CurrentVersion\Policies for machine-wide settings.[120] This process ensured consistent enforcement across NT 4.0 workstations and servers, supporting features like password policies and access controls, though limited to binary file formats without advanced scoping.[121] The transition to Windows 2000 introduced Group Policy Objects (GPOs) as a more robust replacement, prompting migration of legacy policies via tools like the Group Policy Migration Utility (Gpolmig.exe), which converted NTConfig.pol and Config.pol settings into equivalent GPO configurations stored in Active Directory.[122] Windows 2000 and later versions maintained backward compatibility modes, allowing down-level clients (such as Windows 9x and NT 4.0) to process legacy .pol files from NETLOGON shares if no GPO was defined, though this required explicit enabling of compatibility processing.[118] Legacy system policies present significant security risks by modern standards, primarily due to the absence of encryption in .pol files, which stored sensitive configuration data in plaintext or weakly protected binary formats vulnerable to tampering or interception on networks.[123] Additionally, their file-based nature lacked granular auditing, access controls, or versioning, making them susceptible to unauthorized modifications and incompatible with contemporary threat models like ransomware targeting configuration stores.[124] These mechanisms are obsolete in Windows 11, with no native support for .pol file processing or Poledit.exe, as Group Policy has fully supplanted them for policy enforcement. However, remnants persist in compatibility layers, such as the retention of legacy Registry keys under HKCU\Software\Microsoft\Windows\CurrentVersion\Policies for backward-compatible applications, though their use is discouraged.Virtualization Techniques
INI File Virtualization
INI File Virtualization is a compatibility layer in the Windows operating system designed to support legacy applications that rely on INI files for configuration by redirecting their API calls to the Windows Registry. This redirection allows older software, originally developed for pre-Registry systems like Windows 3.x or MS-DOS, to operate seamlessly on modern Windows versions without accessing or creating physical INI files on disk. The feature primarily targets functions in the Win32 API, such as GetPrivateProfileString and WritePrivateProfileString, which traditionally read from and write to INI files but are intercepted to query or update registry keys instead.[125][126] Introduced in Windows 95 and Windows NT 4.0, with enhancements in Windows XP through the Application Compatibility Infrastructure, including shims from the Microsoft Application Compatibility Toolkit, this virtualization intercepts INI-related API calls and maps them to per-user registry locations, such as HKCU\Software\Classes for class associations or application-specific subkeys under HKCU\Software. These shims transparently modify the behavior at runtime, ensuring that data intended for private INI profiles is stored in the user's registry hive (HKEY_CURRENT_USER) rather than system-wide files or the global HKEY_LOCAL_MACHINE hive. This per-user isolation prevents conflicts in multi-user scenarios and maintains system integrity by avoiding writes to protected locations. The virtualized data persists within the user hive and does not affect actual INI files, even if they exist elsewhere on the system.[127][128] Triggers for INI File Virtualization typically occur when an application is flagged for compatibility support, such as through an embedded manifest, the program's compatibility mode settings in its properties, or automatic detection for 16-bit applications running under the Windows on Windows (WOW) subsystem. For instance, a legacy app calling GetPrivateProfileString for a section in a non-existent INI file will prompt the system to consult the IniFileMapping registry key under HKLM\Software[Microsoft](/page/Microsoft)\Windows NT\CurrentVersion, where predefined mappings redirect the operation to the appropriate registry path; if no global mapping exists, shims may dynamically route it to a user-specific equivalent in HKCU. This process ensures backward compatibility without altering the application's code.[125] Despite its utility, INI File Virtualization is limited to basic read and write operations via the targeted APIs and does not emulate advanced INI file behaviors, such as multi-threaded access, file sharing, or complex parsing beyond simple key-value pairs. It serves as a transitional aid rather than a complete replacement for file-based configuration. In contemporary Windows versions, including Windows 11, the feature sees minimal usage as Microsoft encourages developers to adopt native Registry APIs, XML-based configurations, or other modern stores; legacy applications depending on INI virtualization may trigger compatibility warnings or require explicit shims via the Application Compatibility Toolkit for sustained support.[127][129]Registry Virtualization
Registry virtualization in the Windows operating system encompasses several mechanisms designed to isolate and redirect registry accesses, primarily for ensuring compatibility between different application architectures and enhancing security through privilege separation. These techniques allow applications to operate in isolated environments without interfering with system-wide or other users' data, by transparently redirecting read and write operations to virtualized locations. Introduced progressively across Windows versions starting from Windows XP for 32/64-bit compatibility and Windows Vista for user account control, these features maintain backward compatibility while mitigating potential conflicts or security risks.[61][130] One key aspect is the Windows-on-Windows 64-bit (WOW64) subsystem, which provides registry redirection for 32-bit applications running on 64-bit Windows systems. Under WOW64, 32-bit processes receive a separate logical view of the registry, where accesses to certain keys—such as HKEY_LOCAL_MACHINE\Software—are redirected to HKEY_LOCAL_MACHINE\Software\WOW6432Node to prevent conflicts with 64-bit applications. This redirection is handled by the registry redirector component, which intercepts API calls like RegOpenKeyEx and RegCreateKeyEx, ensuring that 32-bit apps interact only with their designated namespace without affecting the native 64-bit registry. The mechanism is automatic and transparent, applying to specific hives including HKEY_LOCAL_MACHINE\Software, HKEY_LOCAL_MACHINE\System (for current control set), HKEY_CURRENT_USER\Software\Classes, and HKEY_CLASSES_ROOT.[61][23][131] User Account Control (UAC) virtualization, introduced in Windows Vista and continuing in subsequent versions, addresses compatibility for legacy applications that attempt to write to protected registry areas without elevated privileges. When a non-elevated process tries to write to restricted locations such as HKEY_LOCAL_MACHINE\Software, the operation fails by default due to access denied errors; however, UAC virtualization redirects these writes to a per-user virtual store in HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\Software (or similar paths for other protected keys). This virtualized data is stored in the user's registry hive under the VirtualStore subkey and is only visible to the originating user and process, preventing global modifications while allowing the application to function as if it succeeded. Virtualization applies selectively to interactive, 32-bit processes that do not request elevation and is disabled for 64-bit processes, services, or applications with UAC-aware manifests.[130][132][133] In modern Windows versions like Windows 10 and 11, the AppContainer execution environment provides further isolation for sandboxed applications, such as those packaged with MSIX or running in UWP contexts. AppContainers enforce a restricted profile where applications receive an isolated registry view, preventing access to system-wide keys and limiting interactions to a private namespace derived from the app's SID (Security Identifier). This includes virtualized access to HKEY_CURRENT_USER subkeys and restricted reads from HKEY_LOCAL_MACHINE, ensuring that sandboxed apps cannot read or write to other users' or system data. The isolation is managed by the kernel's security model, using capabilities declared in the app manifest to grant minimal necessary permissions.[134][135] Developers can detect and manage these virtualization layers through Windows APIs. For instance, the IsWow64Process function determines if a process is running under WOW64, allowing applications to adjust behavior accordingly, such as using 64-bit specific paths. To opt out of UAC virtualization, applications can include a manifest specifying a requestedExecutionLevel of requireAdministrator, which prompts for elevation and bypasses redirection, or asInvoker to indicate UAC awareness without virtualization. Similarly, AppContainer apps can declare extended capabilities in their package manifest to disable certain virtualizations if broader access is required, though this increases security risks.[136][133][137] These redirection mechanisms introduce a performance overhead primarily through additional input/output operations for intercepting and rerouting registry calls, though the impact is generally minimal in typical usage due to the lightweight nature of the redirector layers. In scenarios with frequent registry accesses, such as installation or configuration routines, this can result in slight latency compared to direct hive operations.[61][130]Criticisms and Limitations
Performance Drawbacks
The Windows Registry's design allows for cumulative growth, or "bloat," in its hive files due to incomplete software uninstalls, accumulated entries from repeated installations, and unremoved temporary data, resulting in fragmented structures that expand significantly on systems with heavy usage. In such environments, individual hives like SYSTEM or SOFTWARE can exceed 1 GB, and in extreme cases reach over 2 GB, leading to increased disk space consumption and memory pressure.[138][139] This bloat directly impacts system performance by causing delays in user logons, as the larger hives require more time to load and process during initialization, potentially triggering errors such as insufficient system resources (0x800705AA). Bloated hives also contribute to general slowdowns, including errors in the system event log and reduced responsiveness under load, as the operating system allocates more resources to managing the expanded data structures.[140][138] Registry access involves synchronous input/output (I/O) operations for reading from and writing to hive files on disk, particularly during boot when hives are loaded into memory and during periodic flushes to ensure data persistence, which introduces latency compared to in-memory operations. This overhead slows system startup and application launches that rely on frequent Registry queries, as threads block until I/O completes, exacerbating delays on mechanical hard drives or under high contention.[141][142] The Registry does not support built-in full-text indexing or efficient search mechanisms, forcing tools like Regedit to rely on linear traversal of the hierarchical key structure, which becomes inefficient and time-intensive for bloated or complex hives containing millions of entries. This lack of optimized querying contributes to prolonged search times during troubleshooting or maintenance, often taking minutes or longer without third-party indexing aids.[143] In comparisons to simpler flat file systems like legacy INI files, the Registry's binary, hierarchical format imposes greater overhead for basic read operations due to the need for parsing and navigation, making it slower for straightforward configuration retrievals despite advantages in data organization. A cluttered Registry can thus prolong overall boot times by contributing to inefficient resource loading, though modern optimizations like prefetching in Windows 11 mitigate some impacts.[144][145]Maintenance Challenges
One significant maintenance challenge in the Windows Registry arises from orphaned entries, which are leftover keys and values created by software installations that remain after uninstallation. These remnants, often found under paths likeHKEY_LOCAL_MACHINE\SOFTWARE or HKEY_CURRENT_USER\Software, can accumulate over time, potentially leading to minor bloat but rarely causing functional issues unless they conflict with new installations. Manual cleanup is typically required using the Registry Editor (regedit.exe) to search and delete specific invalid entries, such as those appearing in the Add/Remove Programs list, to avoid referencing non-existent applications.[146][147]
Registry corruption poses another critical risk, particularly from power failures or unexpected shutdowns that interrupt hive writes, resulting in inconsistent data structures. In versions prior to Windows Vista, the Registry lacked atomic transaction support, meaning multi-step updates could leave partial changes if interrupted, exacerbating corruption during events like power loss. Such incidents often manifest as boot failures or application errors, requiring restoration from backups or repair tools like the System File Checker (sfc /scannow).[148][149]
Third-party registry cleaning tools, such as CCleaner, introduce substantial pitfalls by aggressively scanning for and removing entries deemed invalid, which can inadvertently delete active keys essential for system or application functionality. Microsoft explicitly advises against their use, noting that these tools often cause more harm than benefit, including system instability, boot loops, or broken software dependencies, as the Registry's design minimizes the impact of minor invalid entries. Overzealous cleaning has been reported to disrupt core components like shell extensions or driver registrations, necessitating full system restores in severe cases.[150][151]
Effective best practices for Registry maintenance emphasize caution and built-in tools over aggressive interventions. Administrators should regularly export hives via the Registry Editor's "File > Export" function before any modifications, creating point-in-time backups stored as .reg files for selective restoration. Contrary to common myths, defragmenting the Registry is ineffective and unnecessary after Windows XP, as hives are memory-mapped files not subject to traditional fragmentation impacts on modern NTFS volumes; Microsoft does not recommend such operations, which can instead introduce risks without performance gains. For routine upkeep, leveraging System Restore points or the built-in Disk Cleanup utility suffices to manage temporary files indirectly affecting the Registry, while avoiding unverified cleaners preserves stability.[152]
In enterprise environments, auditing Registry changes across domains adds complexity due to the need for centralized monitoring in Active Directory setups. Group Policy Objects (GPOs) can enforce advanced audit policies, such as enabling Event ID 4907 for tracking modifications to object auditing settings, including Registry keys, but this generates voluminous logs requiring tools like Event Viewer or SIEM integration for analysis. Challenges include scaling audits to thousands of endpoints without performance overhead, ensuring consistent policy application via domain controllers, and distinguishing legitimate changes (e.g., software deployments) from anomalies, often necessitating custom scripts or third-party compliance solutions aligned with Microsoft's baseline recommendations.[153][154][155]
Alternatives and Equivalents
Historical Predecessors
Prior to the introduction of the Windows Registry, MS-DOS relied on plain text configuration files located in the root directory of the boot drive to manage system initialization and environment settings. The CONFIG.SYS file contained commands to configure hardware components, load device drivers, and set basic system parameters such as memory management and file buffers. For instance, it could specify the number of files and buffers available to MS-DOS using directives likeFILES=30 and BUFFERS=20. Complementing this, the AUTOEXEC.BAT file served as an executable batch script executed after CONFIG.SYS during the boot process, primarily to define environment variables, set the search PATH for executables, and launch automatic programs or prompts. These files provided essential but rudimentary control over the operating environment, limited to sequential command execution without support for complex data structures.[7]
With the advent of graphical Windows environments starting from Windows 3.0 in 1990, configuration shifted to INI (initialization) files, which were structured text files using a simple key-value format organized into sections. The core system files included WIN.INI, which handled user interface settings such as desktop colors, fonts, and program associations, and SYSTEM.INI, responsible for hardware drivers, virtual memory allocation, and 386 Enhanced mode configurations for multitasking. Applications typically created their own private INI files in the Windows directory or user folders, leading to a decentralized storage of settings across multiple files. This approach allowed for human-readable edits but introduced significant challenges as Windows evolved.[7]
Key limitations of these INI files stemmed from their flat structure and implementation constraints. They supported only two levels of organization—top-level sections and key-value pairs—lacking true hierarchy for nested configurations, which made managing complex relationships difficult. File size was capped at 32 KB, restricting scalability for growing applications. In multiuser environments like Windows NT, the default storage in the shared Windows directory created security and concurrency issues, as files lacked per-user isolation and could be overwritten by concurrent access without granular permissions. Searching and maintaining scattered INI files across the system was cumbersome, often leading to version conflicts during software updates or installations.[156][7]
To ensure backward compatibility during the shift to a centralized database, early implementations of the Registry in Windows 95 and later versions incorporated mechanisms to map legacy INI file contents automatically. For example, entries from WIN.INI and SYSTEM.INI were migrated to specific Registry hives, such as HKEY_CURRENT_USER\Software[Microsoft](/page/Microsoft)\Windows for user settings, while tools like Ini2Reg allowed explicit conversion of application INI sections into Registry keys during installation. This partial support enabled older 16-bit applications to continue reading from INI files via API redirection, bridging the transition without immediate breakage.[157][158]
In parallel with early Windows developments, other operating systems employed similar decentralized text-based configuration approaches. Unix-like systems, originating in the 1970s, centralized miscellaneous administrative files in the /etc directory, which evolved into the primary repository for system-wide settings such as user accounts (/etc/passwd), networking (/etc/hosts), and services (/etc/inittab). This flat file model, while flexible for manual editing, shared issues like lack of hierarchy and potential for parsing errors, influencing later directory service concepts but remaining distinct from Windows-specific evolutions.[159]
Cross-platform Comparisons
In Linux distributions, system-wide configurations are managed through a hierarchy of plain-text files in the /etc directory, as standardized by the Filesystem Hierarchy Standard (FHS). This directory hosts files that control various system behaviors, such as /etc/fstab for defining file system mount points and options. For desktop environments like GNOME, user-specific settings are handled by dconf, a low-level key-based configuration database that serves as the backend for the GSettings API; GSettings organizes preferences into schemas consisting of key-value pairs, often serialized in a binary format but editable via tools that support GVariant data types.[160] On macOS, application and user preferences are stored in property list (plist) files, which are structured documents in either XML or binary format, typically located in the ~/Library/Preferences directory for per-user settings. Thedefaults command-line utility provides a unified interface for reading, writing, and managing these plist files across domains, allowing developers and administrators to manipulate configurations programmatically without directly editing the files.
Beyond traditional OS mechanisms, many modern cross-platform applications adopt lightweight, human-readable formats like JSON or YAML for configuration; for example, Docker uses YAML files in its Compose specification to define services, networks, and volumes for container orchestration. Similarly, some applications employ SQLite databases as a portable, self-contained storage solution for configurations, treating the database file as an application-specific format that supports structured queries and ACID transactions without requiring a separate server.[161]
Compared to the Windows Registry's centralized, binary hierarchical database, these text-based or structured alternatives offer advantages in accessibility, such as direct editing with standard text editors and seamless integration with version control systems like Git for tracking changes. However, they often lack the Registry's tight system integration, resulting in more fragmented storage that requires application-specific tools for management. Within Windows itself, the Settings app in Windows 11 increasingly relies on a JSON-based database for certain user interface configurations, aiming to reduce direct dependence on the Registry for modern experiences.