.reg script to add registry string

Posted on 2012-03-14
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 300 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!


Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

LVL 83

Accepted Solution

oBdA earned 200 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
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.

777 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