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
607 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

726 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