Solved

batch file to add/change registry

Posted on 2009-07-13
4
678 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 500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

622 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