Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
programming4us
Windows 7

Using Advanced System Management Tools : Editing the Registry (part 3) - Using .Reg Files to Automate Registry Changes

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
3/18/2011 6:12:09 PM

7. Using .Reg Files to Automate Registry Changes

The .reg files created by the Export command in Registry Editor are plain text, suitable for reading and editing in Notepad or any similar editor. Therefore, they provide an alternative method for editing your registry. You can export a section of the registry, change it offline, and then merge it back into the registry. Or you can add new keys, values, and data to the registry by creating a .reg file from scratch and merging it. A .reg file is particularly useful if you need to make the same changes to the registry of several different computers. You can make and test your changes on one machine, save the relevant part of the registry as a .reg file, and then transport the file to the other machines that require it.

Figure 3 shows a .reg file. In this case, the file was exported from the HKCU\Software\ Microsoft\Windows\CurrentVersion\Explorer\Advanced key, shown in Figure 4.

Figure 3. A .reg file is a plain-text file suitable for offline editing. This .reg file was exported from the key shown in Figure 4.


Figure 4. This key's name, values, and data are recorded in the .reg file shown in Figure 3.


7.1. Identifying the Elements of a .Reg File

As you review the examples shown in the two figures, note the following characteristics of .reg files:

  • Header line The file begins with the line Windows Registry Editor Version 5.00. When you merge a .reg file into the registry, Registry Editor uses this line to verify that the file contains registry data. Version 5 (the version shipped with Windows 7) generates Unicode text files, which can be used in Windows XP, Windows 2000, and Windows Vista, as well as Windows 7. If you want to share registry data with a system running Windows 95/98/Me or Windows NT, select the Win9x/NT4 Registration Files option when you export the file in Registry Editor. To create from scratch a .reg file that's suitable for import into Windows 95/98/Me or Windows NT, use the header REGEDIT4 instead of Windows Registry Editor Version 5.00.

  • Key names Key names are delimited by brackets and must include the full path from the root key to the current subkey. The root key name must not be abbreviated. (Don't use HKCU, for example.) Figure 22-21 shows only one key name, but you can have as many as you please.

  • The default value Undefined default values do not appear in .reg files. Defined default values are identified by the special character @. Thus, a key whose default REG_SZ value was defined as MyApp would appear in a .reg file this way:

    "@"="MyApp"

  • Value names Value names must be enclosed in quotation marks, whether or not they include space characters. Follow the value name with an equal sign.

  • Data types REG_SZ values don't get a data type identifier or a colon. The data directly follows the equal sign. Other data types are identified as shown in Table 1:

    Table 1. Data Types Identified in .Reg Files
    Data TypeIdentifier
    REG_BINARYhex
    REG_DWORDdword
    REG_QWORDhex(b)
    REG_MULTI_SZhex(7)
    REG_EXPAND_SZhex(2)

    A colon separates the identifier from the data. Thus, for example, a REG_DWORD value named Keyname with value data of 00000000 looks like this:

    "Keyname"=dword:00000000

  • REG_SZ values Ordinary string values must be enclosed in quotation marks. A backslash character within a string must be written as two backslashes. Thus, for example, the path C:\Program Files\Microsoft Offce\ is written like this:

    "C:\\Program Files\\Microsoft Office\\"

  • REG_DWORD values DWORD values are written as eight hexadecimal digits, without spaces or commas. Do not use the 0x prefix.

  • All other data types All other data types—including REG_EXPAND_SZ, REG_MULTI_ SZ, and REG_QWORD—appear as comma-delimited lists of hexadecimal bytes (two hex digits, a comma, two more hex digits, and so on). The following is an example of a REG_MULTI_SZ value:

    "Addins"=hex(7):64,00,3a,00,5c,00,6c,00,6f,00,74,00,00,75,00,73,00,5c,00,\
    31,00,32,00,33,00,5c,00,61,00,64,00,64,00,64,00,69,00,6e,00,73,00,5c,00,\
    64,00,71,00,61,00,75,00,69,00,2e,00,31,00,32,00,61,00,00,00,00,00,00,00

  • Line-continuation characters You can use the backslash as a line-continuation character. The REG_MULTI_SZ value just shown, for example, is all one stream of bytes. We've added backslashes and broken the lines for readability, and you can do the same in your .reg files.

  • Line spacing You can add blank lines for readability. Registry Editor ignores them.

  • Comments To add a comment line to a .reg file, begin the line with a semicolon.

7.2. Using a .Reg File to Delete Registry Data

.Reg files are most commonly used to modify existing registry data or add new data. But you can also use them to delete existing values and keys.

To delete an existing value, specify a hyphen character as the value's data. For example, to use a .reg file to remove the value ThumbnailSize from the key HKCU\Software\Microsoft\ Windows\CurrentVersion\Explorer, add the following lines to the .reg file:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"ThumbnailSize"=-

To delete an existing key with all its values and data, insert a hyphen in front of the key name (inside the left bracket). For example, to use a .reg file to remove the key HKCR\.xyz\ shell and all its values, add the following to the .reg file:

[-HKEY_CLASSES_ROOT\.xyz\shell]

7.3. Merging a .Reg File into the Registry

To merge a .reg file into the registry from within Registry Editor, open the File menu and click Import. Registry Editor adds the imported data under the appropriate key names, overwriting existing values where necessary.

The default action for a .reg file is Merge—meaning merge with the registry. Therefore, you can merge a file into the registry by simply double-clicking it in Windows Explorer and answering the confirmation prompt.

Other -----------------
- Using Advanced System Management Tools : Editing the Registry (part 2) - Backing Up Before You Edit & Browsing and Editing with Registry Editor
- Using Advanced System Management Tools : Managing Services
- Using the Windows 7 Task Scheduler (part 2) - Creating a Task
- Using the Windows 7 Task Scheduler (part 1)
- Using Microsoft Management Console (part 2) - Creating Your Own MMC Consoles
- Using Microsoft Management Console (part 1)
- Using Advanced System Management Tools : Finding and Decoding Information in System Information
- Using Advanced System Management Tools : Viewing System Information
- Security Essentials - Preventing Unsafe Actions with User Account Control
- Security Essentials - Stopping Spyware with Windows Defender
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server