Logo
CAR REVIEW
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
PREGNANCY
 
 
Windows 7

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

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
- Security Essentials - Blocking Viruses and Worms with an Antivirus Program
- Blocking Intruders with Windows Firewall (part 2) - Allowing Connections Through the Firewall
- Blocking Intruders with Windows Firewall (part 1)
- Monitoring Your Computer's Security
- Recording and Watching TV
- Using Windows Live Web Services
- Using Windows Live Programs (part 3) - Using Windows Live Photo Gallery
- Using Windows Live Programs (part 2) - Using Windows Live Mail
- Using Windows Live Programs (part 1) - Obtaining a Windows Live ID & Using Windows Live Messenger
- Using Speech Recognition and Voice Commands
 
 
Most view of day
- Customizing Windows 7 : Change the Windows 7 Color Scheme
- Sharepoint 2013 : Backup and Restore (part 3) - Unattached Content Database Data Recovery
- Sharepoint 2013 : Backup and Restore (part 2) - Export and Import - Using PowerShell, STSADM, Central Administration
- Preparing Windows PE : Setting up the Environment
- SQL Server 2008 R2 : A Performance Monitoring Approach (part 2) - Monitoring the Processors
- Communicating with Internet Email : Sending Messages (part 2) - Setting Send Options, Maintaining Outlook Express
- Microsoft Dynamics CRM 4.0 : SharePoint Integration - Store Attachments in SharePoint Using a Custom Solution
- Extending Dynamics GP with Free Software : Capturing Screenshots and sending an E-mail for support
- Microsoft Exchange Server 2010 : Creating and Managing Accepted Domains (part 2) - Creating Accepted Domains
- Planning Deployment : Starting Deployment Workbench, Updating BDD 2007 Components
Top 10
- Windows Phone 8 : Scheduled Tasks - Scheduled Task API Limitations
- Windows Phone 8 : Scheduled Tasks - Updating Tiles Using a Scheduled Task Agent
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 5) - Editing an Existing To-Do Item
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 4) - Creating the To-Do Item Shell Tile, Saving a To-Do Item
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 3) - Debugging Scheduled Tasks
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 2) - TodoService, TodoItemViewModel
- Windows Phone 8 : Scheduled Tasks - To-Do List Scheduled Task Sample (part 1) - TodoItem,TodoDataContext
- Windows Phone 8 : Scheduled Tasks - Using Scheduled Tasks
- Windows Phone 8 : Scheduled Tasks - Background Agent Types
- Windows Phone 8 : Windows Phone Toolkit Animated Page Transitions - Reusing the Transition Attached Properties
 
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro