Solved

write a DOS script to add a string value to a registry key for multiple server within the same WIN2K3 domain.

Posted on 2011-02-25
6
575 Views
Last Modified: 2012-05-11
if I need to add a string value let's say iPermit=1 under the following register key: hklm->system->currentcontrolset->control->session manager->environment of multiple domain servers, how do I write a DOS script to do that?  

Thanks
0
Comment
Question by:nav2567
6 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 350 total points
ID: 34984484
For example by enumerating those servers manually in a FOR:
@echo off
for %%S in (
   server1  server2  server3
) do reg add "\\%%S\HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v "iPermit" /d 1 /f

Open in new window

0
 
LVL 2

Assisted Solution

by:Mattrw
Mattrw earned 75 total points
ID: 34984553
Generate the registry setting on a server e.g. iPermit=1 under HKLM.  Right click and export, you will use this as the example.

Open group policy gpedit.msc or under Active Directory and create a new group policy.  Under Computer settings, Windows Settings, Scripts (Startup / Shutdown).  Double click startup.  Under the Script Parameters window type regedit.exe /s path of .reg file

Change the security options to apply to your desired servers, so remove Authenticated Users.

The path of the reg file will need to be a share e.g. \\server\share with full permissions for the computers that are going to be accessing it.  Once the server has the policy, reboot it and it will post the .reg file into your servers.
0
 
LVL 8

Assisted Solution

by:subhashchy
subhashchy earned 75 total points
ID: 34984562
If the user under which batch is running does not have admin rights on the servers then you should map a drive first using admin account and then execute the reg add script.

Please  replace administraor and password with the actual username password in below script.

@echo off
for /f %%a in (list.txt) do (
echo processing server %%a
net use \\%%a\c$ /u:administrator password
reg add "\\%%a\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Ipermit /t Reg_SZ /d 1 /f
)

Open in new window

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:nav2567
ID: 34984621
Thanks.  

One last qustion if you do not mind.  If I need to replace a registry key with the current user ID - %username% of the system, how do I do that?  

For example, if the login id is tomt, running the script will update the registry value under hklm->system->currentcontrolset->control->session manager->environment ->iuser to become tomt\\server1.  If login id is maryh, after running the script will update the registry value under hklm->system->currentcontrolset->control->session manager->environment ->iuser to become maryh\\server1.  

Thanks.  
0
 

Author Comment

by:nav2567
ID: 34984638
Please disregard.  I will go ahead and grant points and create another question.....

Thanks everyone.  
0
 

Author Closing Comment

by:nav2567
ID: 34984641
thanks.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Resolve DNS query failed errors for Exchange
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now