Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

batch file to add/change registry

Posted on 2009-07-13
4
Medium Priority
?
679 Views
Last Modified: 2012-05-07
Please someone help me to create batch file to add following registry.
This has to be batch file, not vbs.

Thanks.
"HKEY_LOCAL_MACHINE\SOFTWARE\ManagementSoftware\4.0.0\WIN\","\\server\CMN\4.0.0\WIN\","REG_SZ"
"HKEY_LOCAL_MACHINE\SOFTWARE\ManagementSoftware\CMN\","\\server\CMN\","REG_SZ"
"HKEY_LOCAL_MACHINE\SOFTWARE\ManagementSoftware\CMN\DBLocation","\\server\CMN\","REG_SZ"
"HKEY_CLASSES_ROOT\Installer\Products\44AFB2215A150C7448D73E8EC48716A0\SourceList\Net\1","\\server\CMN\","REG_EXPAND_SZ"

Open in new window

0
Comment
Question by:kimakabane
[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
4 Comments
 
LVL 2

Expert Comment

by:regnighc
ID: 24841347
You cant add the keys using a bat file but you can use a bat file to import a reg file.

Please see here  http://www.robvanderwoude.com/regedit.php
0
 

Author Comment

by:kimakabane
ID: 24841416
Thanks.

Is it possible to add registry if it is vbs?
Do you know how to add "CPAU" usage in its vbs file?

I need to let users to run script on network share folder to change registry which domain user have no access.
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 24841572
Your information is out of date, regnighc.  Registry entries can be added directly in batch scripts with the reg add command.  Reg.exe is included by default in Windows XP and up.

kimakabane, I don't understand the entries in your original post.  What are the keys, what are the values, and what is the data within those values?
0
 
LVL 3

Accepted Solution

by:
cclassen earned 2000 total points
ID: 24844484
Shift-3 is correct.  You can use Reg Add to do this in batch.

I took a stab at guessing the values from the strings you have posted and came up with this.  This script will loop through a list of machines (in list.txt; should be in the same directory as the batch file).  If you don't need to run through a list, just use

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ManagementSoftware\4.0.0" /v "WIN" /t "REG_SZ" /d "\\server\CMN\4.0.0\WIN\"
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ManagementSoftware\" /v "CMN" /t "REG_SZ" /d "\\server\CMN\"
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\ManagementSoftware\CMN\" /v "DBLocation" /t "REG_SZ" /d "\\server\CMN\"
reg add "HKEY_CLASSES_ROOT\Installer\Products\44AFB2215A150C7448D73E8EC48716A0\SourceList\Net\" /v "1" /t "REG_EXPAND_SZ" /d "\\server\CMN\4.0.0\WIN\"


****

for /f %%i in (list.txt) do call :main %%i
goto :eof
 
:main
set vCurrentPC=%1
reg add "\\%vCurrentPC%\HKEY_LOCAL_MACHINE\SOFTWARE\ManagementSoftware\4.0.0" /v "WIN" /t "REG_SZ" /d "\\server\CMN\4.0.0\WIN\"
reg add "\\%vCurrentPC%\HKEY_LOCAL_MACHINE\SOFTWARE\ManagementSoftware\" /v "CMN" /t "REG_SZ" /d "\\server\CMN\"
reg add "\\%vCurrentPC%\HKEY_LOCAL_MACHINE\SOFTWARE\ManagementSoftware\CMN\" /v "DBLocation" /t "REG_SZ" /d "\\server\CMN\"
reg add "\\%vCurrentPC%\HKEY_CLASSES_ROOT\Installer\Products\44AFB2215A150C7448D73E8EC48716A0\SourceList\Net\" /v "1" /t "REG_EXPAND_SZ" /d "\\server\CMN\4.0.0\WIN\"
goto :eof
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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