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
604 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 69

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Learn about cloud computing and its benefits for small business owners.
Synchronize a new Active Directory domain with an existing Office 365 tenant
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…
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 …

829 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