Solved

batch file to add/change registry

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending Attachment via CDO 3 70
change the windows script file to BAT 10 49
Batch file or script with password 22 65
Need VBA code to change date format of Column A 5 24
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

860 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