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
585 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
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…
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

929 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

15 Experts available now in Live!

Get 1:1 Help Now