Solved

Edit Registry Key via Batch File

Posted on 2016-09-02
8
42 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Great thanks, I'll try that.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Newbie0000
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you so much, works like a charm now!
0
 

Author Closing Comment

by:Newbie0000
Comment Utility
Thanks again!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

771 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

12 Experts available now in Live!

Get 1:1 Help Now