Re: The way of the Tweek Windows XP Learn a little more about your Registry Part 2
REG files
If you highlight a key and select File > Export, you will be asked to enter a filename. The end result is a .REG file which contains all the entries in and below the key you highlighted. You can even backup the entire registry by this method. However normally you'd use it to quickly backup a key you were about to remove or edit.
REG files are nothing more than plain-text files. The REG extension is associated with RegEdit so double-clicking a REG file will allow you to "merge" (import) the data contained therein - thus restoring the entries to what they were before you edited them. However, there are is one drawback: new entries added since the REG file was created will not be removed - only existing entries are overwritten, and missing entries restored. However, for most edits this is perfectly adequate.
The REG file format is relatively simple. Take a look at the Registry Hacks page for some examples. At the very top of the file is the identifier, REGEDIT4. This must appear at the top of all REG files on a line of its own. Below this are two blank lines (although one is sufficient) followed by the first key, which is surrounded by square braces []. If there are any data values for this key, they are listed immediately below it in "data name"="data value" format (for string data types). Other data types have their own specific format, with the type of data immediately following the equals sign (=), e.g., "data name"=hex:00000001 for an 8-bit binary value, and "data name"=dword:00,00,00,00 for double-word values (4 bytes).
Every key has a default value. However, not all default values actually contain data (they are not set). But since the default value has no name (the name is actually the name of the key it belongs), the "@" symbol is used instead. The default value is always a string type so, whenever one is set, the REG file will show an entry like @="default value". One such use for a default value is to specify a default key immediately below the default value's key. We'll look at this in greater detail shortly.
After all values for a particular key are listed, a blank line separates it from the next key. Notice how keys are listed in hierarchical form, from the parents to the children. This is because missing keys need to be recreated, and this can only be achieved if the parent key(s) exist. Keys are added (if missing) in the order they appear, thus parents must always appear before their children. However, the order of the parents at similar levels may not be alphabetical, and the values themselves may not be alphabetical either. The order they appear in is the order they were created in. You could spend time sorting the order but there's very little point in doing so. A particular key or value will be found just as quickly regardless of its order.
The REG file continues in this fashion, listing keys and their respective values, separating each key with a blank line. At the end of the file there must be at least one blank line (this is common of most script files - since the carriage return/line-feed at the end of each line is treated as a part of the line).
The observant amongst you may have noticed file and folder pathnames in the data values use double-forward-slashes ("\\") rather than the normal single-forward-slash ("\"). This is simply because the single forward-slash is a special "tag" character, used to clarify the character that follows it. In other words, the two characters are treated as a single character. For example, "\t" translates as a tab character, while "\n" translates as a carriage-return/line-feed. Since the forward-slash is a special character, it can't be used in registry pathnames. However, a double-forward-slash clarifies that the second forward-slash is a genuine forward-slash. The first is therefore ignored. If you look in the registry you'll see the double-slashes are correctly shown as single-slashes.
If you've looked through my Registry Hacks you may have discovered one or two you'd like to try. Now would be a good opportunity to put your newly found skills into action, while you observe the REG inserting its entries. Simply use RegEdit to navigate to the appropriate key that the REG will edit, and look at the current entries. Merge the REG file (by double-clicking it) then hit F5 to refresh RegEdit. Your new entries will appear in the editor. Note that some settings (local machine settings in particular) will require a reboot to take full effect. These types of settings are read at bootup and remain in memory throughout. Others (particularly current user settings) may require a logoff in order to take effect. However, for the most part, settings will take effect from the moment you merge them - although the program that uses those settings may require refreshing itself (or even to be shut down and re-run) before the settings take effect. If in doubt, reboot.
A few paragraphs ago I mentioned that REG files couldn't remove new entries added since making the REG file. That isn't entirely true. To remove entries using REG files you need to remove the entire key the entry appears in, and then restore the other entries. For example, suppose I have a key for my own software (HKEY_LOCAL_MACHINE\Software\PCForrest) and want to remove the data value named "MyApp". I would first export the [HKEY_LOCAL_MACHINE\Software\PCForrest] key, and then move the "MyApp" line to the top of the file, under the same key but with a leading minus (-), like so:
REGEDIT4
[-HKEY_LOCAL_MACHINE\Software\PCForrest]
"MyApp"="This Entry Should be Removed"
[HKEY_LOCAL_MACHINE\Software\PCForrest]
"ThisApp"="This Entry Belongs Here"
"ThatApp"="This Entry Also Belongs Here"
Note that when removing keys, it doesn't matter what values you place below them. I include them merely to show precisely what I want to delete. However, be aware that any values in addition to the ones in this file (and any sub-keys within it) will also be deleted |