Solved

User input in registry file

Posted on 2011-03-05
4
647 Views
Last Modified: 2012-06-27
Hi,
    I have a registry file (.reg) that needs to take an input from the user and use it internally in the file before making mods to the registry..Please see below

[HKEY_LOCAL_MACHINE\SOFTWARE\MyCorporation\MySoftware]
"Port"="COM5"

Open in new window


I want the "COM5" to come from user-input instead of hard-coding it, or having the user edit the registry file.  

Any help is appreciated!

Thanks
0
Comment
Question by:arunykand
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:oBdA
ID: 35043695
Use a batch file instead of a registry file, for example like this:
@echo off
set /p Port=Please enter the port number: COM
if "%Port%"=="" goto :eof
reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\MyCorporation\MySoftware" /v "Port" /t REG_SZ /d "COM%Port%"

Open in new window

That could of course be as well changed to a menu, and/or restricted to certain values.
0
 

Author Comment

by:arunykand
ID: 35043775
Ok, so you're saying put everything into a batch file and let the reg.exe add take care of it?

I was also using the .reg file to add other items & remove items, how would I implement that into the batch file along with what you have given me?

Ex:

//Modify reg value
;[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters]
;"maximumpasswordage"=dword:00000078

//Delete reg Value

;[HKEY_USERS\.DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]
;"OSK.exe"=-

Thanks

0
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 35043794
"reg.exe /?", "reg.exe add /?" and reg.exe delete /?" will give you the necessary explanations to expand the script. In the cases above:
@echo off
set /p Port=Please enter the port number: COM
if "%Port%"=="" goto :eof
reg.exe add "HKEY_LOCAL_MACHINE\SOFTWARE\MyCorporation\MySoftware" /v "Port" /t REG_SZ /d "COM%Port%" /f
reg.exe add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters" /v "maximumpasswordage" /t REG_DWORD /d "78" /f
reg delete "HKEY_USERS\.DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v "OSK.exe" /f

Open in new window


And in first the script above I forgot to add a "/f" at the end of the reg command to avoid asking for confirmation, sorry.
0
 

Author Comment

by:arunykand
ID: 35043806
Excellent, thank you!
0

Featured Post

Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Several part series to implement Internet Explorer 11 Enterprise Mode
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now