Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Convert .reg files to .bat files



Convert .reg files to .bat files

How to Convert Registry Files to their Batch File Equivalents
Published by Dwarf
11 May 2010
Published by

How to Convert Registry Files to their Batch File Equivalents

This Tutorial is a work in progress and is closed for replies. After its completion, it will be opened for replies. In the meantime, if you have any suggestions or spot any glaring omissions/errors, please feel free to PM and/or VM me. Thankyou.

Note   Note
This tutorial will show you the basics of converting registry files so that you can run them as a batch file. This is particularly useful for those files which need administrative privileges to be merged into the registry.


information   Information
The default behaviour of .reg files is to merge into the registry. However, the merge option only operates with the same privileges as the currently logged in user and, unlike running a program, this cannot be elevated to operate with administrative privileges. Basically, modifying registry keys in the HKCR and HKLM branches requires doing so from within an administrative account or from an equivalent batch file that is run with administrative privileges. This is because information there has a system-wide scope. The HKCU branch is different, and the data there can be modified from within a standard or an administrative account, since the information there pertains to the individual user and not the system as a whole.


The examples shown here are just that - they are to show conversion equivalents and are not designed to carry out any specific function.

All examples are located in the following key:

HKEY_CURRENT_USER\Test (.reg file) or HKCU\Test (.bat file)

Actual files will pertain to different sections of the registry, and the equivalent handles (roots) are as follows (.reg file > .bat file):

HKEY_CLASSES_ROOT > HKCR (administrative privileges required)
HKEY_CURRENT_USER > HKCU
HKEY_LOCAL_MACHINE > HKLM (administrative privileges required)
HKEY_USERS > HKU
HKEY_CURRENT_CONFIG > HKCC

The vast majority of registry edits will pertain to one or more of the first three roots listed above.

The primary commands used will be REG ADD and REG DELETE (see below for examples of the syntax).

Code:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Windows\system32>reg add /?
REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]
  KeyName  [\\Machine\]FullKey
           Machine  Name of remote machine - omitting defaults to the
                    current machine. Only HKLM and HKU are available on remote
                    machines.
           FullKey  ROOTKEY\SubKey
           ROOTKEY  [ HKLM | HKCU | HKCR | HKU | HKCC ]
           SubKey   The full name of a registry key under the selected ROOTKEY.
  /v       The value name, under the selected Key, to add.
  /ve      adds an empty value name (Default) for the key.
  /t       RegKey data types
           [ REG_SZ    | REG_MULTI_SZ | REG_EXPAND_SZ |
             REG_DWORD | REG_QWORD    | REG_BINARY    | REG_NONE ]
           If omitted, REG_SZ is assumed.
  /s       Specify one character that you use as the separator in your data
           string for REG_MULTI_SZ. If omitted, use "\0" as the separator.
  /d       The data to assign to the registry ValueName being added.
  /f       Force overwriting the existing registry entry without prompt.
Examples:
  REG ADD \\ABC\HKLM\Software\MyCo
    Adds a key HKLM\Software\MyCo on remote machine ABC
  REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
    Adds a value (name: Data, type: REG_BINARY, data: fe340ead)
  REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail
    Adds a value (name: MRU, type: REG_MULTI_SZ, data: fax\0mail\0\0)
  REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d ^%systemroot^%
    Adds a value (name: Path, type: REG_EXPAND_SZ, data: %systemroot%)
    Notice:  Use the caret symbol ( ^ ) inside the expand string
C:\Windows\system32>
Code:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Windows\system32>reg delete /?
REG DELETE KeyName [/v ValueName | /ve | /va] [/f]
  KeyName    [\\Machine\]FullKey
    Machine  Name of remote machine - omitting defaults to the current machine.
             Only HKLM and HKU are available on remote machines.
    FullKey  ROOTKEY\SubKey
    ROOTKEY  [ HKLM | HKCU | HKCR | HKU | HKCC ]
    SubKey   The full name of a registry key under the selected ROOTKEY.
  ValueName  The value name, under the selected Key, to delete.
             When omitted, all subkeys and values under the Key are deleted.
  /ve        delete the value of empty value name (Default).
  /va        delete all values under this key.
  /f         Forces the deletion without prompt.
Examples:
  REG DELETE HKLM\Software\MyCo\MyApp\Timeout
    Deletes the registry key Timeout and its all subkeys and values
  REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU
    Deletes the registry value MTU under MyCo on ZODIAC
C:\Windows\system32>
Due to the length of this Tutorial, the actual examples will be in the following post.
.

11 May 2010   #1
Dwarf

Windows 8.1 Pro RTM x64
 
 

Now for the examples themselves. They will be displayed in the form of code boxes, with the .reg being shown first followed by the .bat equivalent and finally by how the entry actually appears in the Registry Editor.

This shows how to enter an empty value name (Default) for the key. Note that this CANNOT be deleted without deleting the parent key.

Code:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Test]
@=""
Code:
@ECHO OFF
REG ADD "HKCU\Test" /ve /f
Name:  Capture.PNG
Views: 3594
Size:  20.9 KB

This shows a Default variable with data.

Code:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Test]
@="Some data"
Code:
@ECHO OFF
REG ADD "HKCU\Test" /ve /t REG_SZ /d "Some data" /f
Name:  Capture1.PNG
Views: 3591
Size:  25.9 KB

This shows a DWORD (4 byte, 32-bit) variable and data.

Code:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Test]
"Variable"=dword:f09a0fa9
Code:
@ECHO OFF
REG ADD "HKCU\Test" /v "Variable" /t REG_DWORD /d "f09a0fa9" /f
Name:  Capture2.PNG
Views: 3612
Size:  29.8 KB

This shows a QWORD (8 byte, 64-bit) variable and data.

Code:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Test]
"Variable"=qword:fedcba9876543210
Code:
@ECHO OFF
REG ADD "HKCU\Test" /v "Variable" /t REG_QWORD /d "fedcba9876543210" /f
Name:  Capture3.PNG
Views: 3611
Size:  33.2 KB



My System SpecsSystem Spec
.

12 May 2010   #2
Dwarf

Windows 8.1 Pro RTM x64
 
 

Finally, let's take a look at some real-life cases. Again, these will show the .reg file first followed by its .bat equivalent.

http://www.sevenforums.com/tutorials...text-menu.html

Code:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\exefile\shell\Run with Normal Priority]
@=""
[HKEY_CLASSES_ROOT\exefile\shell\Run with Normal Priority\Command]
@="cmd.exe /c start \"Run with Normal Priority\" /Normal \"%1\""
Code:
@ECHO OFF
REG ADD "HKCR\exefile\shell\Run with Above Normal Priority" /ve /f
REG ADD "HKCR\exefile\shell\Run with Above Normal Priority\Command" /ve /t REG_SZ /d "cmd.exe /c start \"Run with Above Normal Priority\" /AboveNormal \"%%1\"" /f
The "E-mail" command is missing or is unavailable in Excel 2007, in PowerPoint 2007, or in Word 2007

Code:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Messaging Subsystem]
"MAPI"="1"
"CMC"="1"
"CMCDLLNAME"="Mapi.dll"
"CMCDLLNAME32"="Mapi32.dll"
"MAPIX"="1"
"MAPIXVER"="1.0.0.1"
"OLEMessaging"="1"
Code:
@ECHO OFF
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Messaging Subsystem" /v MAPI /t REG_SZ /d 1 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Messaging Subsystem" /v CMC /t REG_SZ /d 1 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Messaging Subsystem" /v CMCDLLNAME t/ REG_SZ /d Mapi.dll /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Messaging Subsystem" /v CMCDLLNAME32 /t REG_SZ /d Mapi32.dll /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Messaging Subsystem" /v MAPIX /t REG_SZ /d 1 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Messaging Subsystem" /v MAPIXVER /t REG_SZ /d 1.0.0.1 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows Messaging Subsystem" /v OLEMessaging /t REG_SZ /d 1 /f
Realtek Equalizer Settings

Code:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{29ec048a-cb02-4173-8d20-bae131a470b9}\FxProperties]
"{69203b66-c559-499c-bb5f-f54563cd7d59},n"="<user preset name n>"
"{36033203-cbc4-4960-9b48-490166ca34c9},n"=hex:41,00,7f,fb,01,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{b69efb25-5ac5-4f32-819e-efbc8ba37d42}\FxProperties]
"{69203b66-c559-499c-bb5f-f54563cd7d59},n"="<user preset name n>"
"{36033203-cbc4-4960-9b48-490166ca34c9},n"=hex:41,00,7f,fb,01,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
  00,00,00,00,00,00,00,00,00,00,00,00,00
Code:
@ECHO OFF
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{29ec048a-cb02-4173-8d20-bae131a470b9}\FxProperties" /v "{69203b66-c559-499c-bb5f-f54563cd7d59},n" /t REG_SZ /d "<user preset name n>" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{29ec048a-cb02-4173-8d20-bae131a470b9}\FxProperties" /v "{36033203-cbc4-4960-9b48-490166ca34c9},n" /t REG_BINARY /d "41007ffb0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{b69efb25-5ac5-4f32-819e-efbc8ba37d42}\FxProperties" /v "{69203b66-c559-499c-bb5f-f54563cd7d59},n" /t REG_SZ /d "<user preset name n>" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{b69efb25-5ac5-4f32-819e-efbc8ba37d42}\FxProperties" /v "{36033203-cbc4-4960-9b48-490166ca34c9},n" /t REG_BINARY /d "41007ffb0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000" /f
My System SpecsSystem Spec
Closed Tutorial

 Convert .reg files to .bat files




Tutorial Tools



Similar help and support threads for2: Convert .reg files to .bat files
Windows 7 Tutorial Category
How to convert .wtv files Media Center
Solved Convert DRM wma files to mp3 for iPod Music, Pictures & Video
can't convert video files Music, Pictures & Video
CONVERT AUDIO FIlES Sound & Audio
How to convert OneNote files? Music, Pictures & Video
looking for free program to convert DVR-MS files Media Center
convert files to pdf Software

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 09:29 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33