Solved

Edit Registry Key via Batch File

Posted on 2016-09-02
8
75 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:Newbie0000
ID: 41781784
Great thanks, I'll try that.
0
 

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
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)
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

713 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