.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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bartender_1Microsoft 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
Bartender_1Microsoft 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
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bartender_1Microsoft 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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.