.reg script to add registry string

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
icecom4Asked:
Who is Participating?
 
oBdACommented:
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

0
 
Christopher McKayMicrosoft Network AdministratorCommented:
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!

:o)

Bartender_1
0
 
icecom4Author Commented:
yes, please, if you don't mind.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
Christopher McKayMicrosoft Network AdministratorCommented:
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!

:o)

Bartender_1
0
 
Christopher McKayMicrosoft Network AdministratorCommented:
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.

:o)

Bartender_1
0
 
icecom4Author Commented:
Thank you for teaching me that!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.