Solved

batch file to add/change registry

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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