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
Solved

Edit Registry Key via Batch File

Posted on 2016-09-02
8
69 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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 Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

856 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