Solved

Edit Registry Key via Batch File

Posted on 2016-09-02
8
56 Views
Last Modified: 2016-09-06
I need to make a change in the registry, I have the new *.reg file but can't seem to get the correct syntax. I manually changed the key and exported the reg.key file.

I have tried the following to edit the key in my batch file:

reg add \\Server\Share\FixSvrName.reg
regedit.exe /s \\Server\Share\FixSvrName.reg
regedit.exe /s "\\Server\Share\FixSvrName.reg"

I need to change the Server name in 2 keys, the key is:

Name = ab 1
Type = REG_EXPAND_SZ
Data = \\Bad Server Name\Share
HKEY_CLASSES_ROOT\Installer\Products\35C4EBB1B4363B44683913E46D625075\SourceList\Net and

Date = Data = \\Bad Server Name\Share
HKEY_CLASSES_ROOT\Installer\Products\B157EEDAEA907AD46985CD9FE0F8E97D\SourceList\Net

Thanks in advance for the help.
0
Comment
Question by:Newbie0000
  • 5
  • 3
8 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 41781638
The correct one is (or the one with the quotes if spaces are involved):

regedit.exe /s \\Server\Share\FixSvrName.reg

Are you sure you are doing this as admin though?
0
 

Author Comment

by:Newbie0000
ID: 41781730
Yes I am, I will try it again. Been working on it so maybe I had an extra space or something. I will also try it in the command line.

Thanks for the response.
0
 
LVL 35

Expert Comment

by:Kimputer
ID: 41781751
In some cases, this is the better solution (in case GUI keeps popping up despite using the /s or /q with regedit).

reg add hkcr\Installer\Products\35C4EBB1B4363B44683913E46D625075\SourceList\Net /v "ab 1" /t REG_EXPAND_SZ /d  "\\Bad Server Name\Share"
0
 

Author Comment

by:Newbie0000
ID: 41781784
Great thanks, I'll try that.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:Newbie0000
ID: 41785961
Hi,

So this works but even with the /f it is prompting me to "overwrite the file"?

reg add "HKEY_CLASSES_ROOT\Installer\Products\35C4EBB1B4363B44683913E46D625075\SourceList\Net" /v "1" /t REG_EXPAND_SZ /d "\\Good Server Name\Share\" /f
0
 
LVL 35

Accepted Solution

by:
Kimputer earned 500 total points
ID: 41786048
reg add "HKEY_CLASSES_ROOT\Installer\Products\35C4EBB1B4363B44683913E46D625075\SourceList\Net" /v "1" /t REG_EXPAND_SZ /d "\\Good Server Name\Share" /f

The last slash causes this problem, and since it's a folder, it should be ok.
0
 

Author Comment

by:Newbie0000
ID: 41786353
Thank you so much, works like a charm now!
0
 

Author Closing Comment

by:Newbie0000
ID: 41786357
Thanks again!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

911 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