Solved

Edit Registry Key via Batch File

Posted on 2016-09-02
8
84 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Outlook 2016 processing loop 4 44
Changing Monitor IDs 3 48
Can't Login to Laptop 18 41
PCIe SATA controller card question 4 32
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.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
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.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

738 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