Go Premium for a chance to win a PS4. Enter to Win


.reg script to add registry string

Posted on 2012-03-14
Medium Priority
Last Modified: 2012-03-14
How can I convert this batch line to a .reg file instead?

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /v "C:\Windows\SysWOW64\PnkBstrA.exe" /t REG_SZ /d "VISTASP1 RUNASADMIN" /f
Question by:icecom4
  • 3
  • 2
LVL 22

Expert Comment

by:Christopher McKay
ID: 37721025
The easiest way to convert it to a reg file would be to go to the registry entry on a computer that this batch file has be run on, and then right click on the key and choose export, then export it as a reg file. Let me know if you need step by step instructions on how to do this.

Hope this helps!



Author Comment

ID: 37721490
yes, please, if you don't mind.
LVL 22

Assisted Solution

by:Christopher McKay
Christopher McKay earned 1200 total points
ID: 37721614
Ok, step by step process is this:

1) Click start,
2) Choose "Run" (If you're on a Vista or Windows 7 machine, you can use the "Search Programs and Files" rather than the "Run" command)
3) type "regedit.exe" (without the quotes)
4) Press "Enter" (You may be prompted by User Account Control to allow the program to make changes to your computer, select "Yes" if you are prompted)
5) In the regedit window, on the left hand pane, browse to "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" (Note that the HKLM will most likely read "Hkey_Local_Machine"
6) Right click on the "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" key and choose "Export"
7) Provide a filename you wish to save the file as, and note the location of the "Save In" folder.
8) Click "Save" button.
9) Close Regedit Window
10) Browse to the location the "Save In" was showing, and your file should be there with the name you gave it.

Hope this helps!


Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 85

Accepted Solution

oBdA earned 800 total points
ID: 37722435
CAREFUL: the way suggested by Bartender_1 is somewhat risky. This method would actually add all values and all keys already present under the "Layers" key before the batch was run to the exported reg file as well, whereas the reg.exe command will just add one single REG_SZ entry. Explaning how to delete any unrelated line would be more complicated than just creating the file directly from the command line...
A reg file always starts with "Windows Registry Editor Version 5.00" (without the quotes) and an empty line after that.
Then add the key in square brackets, and (default is REG_SZ in reg files) just add the value in double quotes, a "=", and the data to set in double quotes as well. Finally double up on the backslashes in the path:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Windows\\SysWOW64\\PnkBstrA.exe"="VISTASP1 RUNASADMIN"

Open in new window

LVL 22

Expert Comment

by:Christopher McKay
ID: 37722471
What oBdA states is true, If you have more entries in this key other than the one you wish to add, my method would capture those as well.

I chose this method because I made the assumption that you would only be running Punk Busters in compatibility mode. If you have other programs that are running in compatibility mode, their registry entries would also be captured, and I should have forewarned against that just in case.

Thanks for pointing out my error oBdA.



Author Comment

ID: 37722926
Thank you for teaching me that!!!!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question