Solved

User input in registry file

Posted on 2011-03-05
4
648 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?

Are you 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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sharepoint 2010 Audit Logs 11 82
Dual boot for S.O 7 33
Sort list of IP addresses 7 40
Run same command on multiple files in Linux 3 0
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
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...
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 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

16 Experts available now in Live!

Get 1:1 Help Now