JordansGhost
asked on
Registry Changes using a script
Further to my earlier question regarding DNS registry settings I now have an issue.
I need to use a script to look up the following registry key
HKEY_LOCAL_MACHINE\SYSTEM\ CurrentCon trolSet\Se rvices\Tcp ip\Interfa ces
Then for each interface that appears in the key it needs to update the following two values
Domain = "mydomain.org"
RegisterAdapterName = 1
I need this to work under a certain username and password as I am going to run the script through the login script.
Can anyone provide a script that will do this
I need to use a script to look up the following registry key
HKEY_LOCAL_MACHINE\SYSTEM\
Then for each interface that appears in the key it needs to update the following two values
Domain = "mydomain.org"
RegisterAdapterName = 1
I need this to work under a certain username and password as I am going to run the script through the login script.
Can anyone provide a script that will do this
ASKER
I know I can add a key. The problem I have is that I need to retreive the adapter GUID's to update the keys for each seperate PC so a script needs to do it. I cannot just stamp the same reg key across all machines.
Your .reg would look like this:
__________________________ __________ __________ __________ __________ __________ _____
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM \CurrentCo ntrolSet\S ervices\Tc pip\Interf aces\INTER FACE_NAME]
"Domain"="mydomain.org"
[HKEY_LOCAL_MACHINE\SYSTEM \CurrentCo ntrolSet\S ervices\Tc pip\Interf aces\INTER FACE_NAME]
"RegisterAdapterName"="1"
__________________________ __________ __________ __________ __________ __________ _____
INTERFACE_NAME would be whatever your registry specifies as the name for that adapter. This would of course be done in notepad then saved with the .reg extension. All this is explained in more detail in the links Fatal_Exception provided as far as how to distribute to your group policy.
//j
__________________________
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM
"Domain"="mydomain.org"
[HKEY_LOCAL_MACHINE\SYSTEM
"RegisterAdapterName"="1"
__________________________
INTERFACE_NAME would be whatever your registry specifies as the name for that adapter. This would of course be done in notepad then saved with the .reg extension. All this is explained in more detail in the links Fatal_Exception provided as far as how to distribute to your group policy.
//j
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sample script
Setting Network Parameters Using WMI (Part 1):
http://www.serverwatch.com/tutorials/article.php/1548421
Setting Network Parameters Using WMI (Part 1):
http://www.serverwatch.com/tutorials/article.php/1548421
All you need is a copy of your .reg file and a simple command line:
regedit /s \\myshare\regkey.reg
No user intervention required.
If you want to have regedit generate the .reg file for you, click on the key you want to distribute, and choose "File" and "'Export". This way there are no worries about typos or any such errors.
Cheers
regedit /s \\myshare\regkey.reg
No user intervention required.
If you want to have regedit generate the .reg file for you, click on the key you want to distribute, and choose "File" and "'Export". This way there are no worries about typos or any such errors.
Cheers
Seems to me that Ramesh answered this correctly, including links to the proper script... Just my opinion of the comments.. :)
ASKER
This question is not abandoned, I have not yet had the time due to a DR test to attempt the resolutions offered
>> including links to the proper script
Thanks William! Let's see how it goes.
Thanks William! Let's see how it goes.
Sure, I would like to see how this turns out too.. :)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, i've managed to put together a script using the the info above so this is just about answered. A small issue.
it works fine on my machine but although it seems to run without error on a users machine it doesnt seem to make the required changes.
Do i need to specify credentials to ensure the user has rights to make the changes. Here is the script
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("S elect SettingID from Win32_NetworkAdapterConfig uration WHERE IPEnabled=True",,48)
For Each objItem in colItems
strnetsettingid = objItem.SettingID
Set objRegistry = _
GetObject("winmgmts:{imper sonationLe vel=impers onate}!\\" _
& strComputer & "\root\default:StdRegProv" )
strKeyPath = "SYSTEM\CurrentControlSet\ Services\T cpip\Param eters\Inte rfaces\" & strnetsettingid
strValueName1 = "Domain"
strValueName2 = "RegistrationEnabled"
strValueName3 = "RegisterAdapterName"
strValueEntry1 = "my.org"
strValueEntry2 = "1"
strValueEntry3 = "1"
objRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath,_
strValueName1, strValueEntry1
objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath,_
strValueName2, strValueEntry2
objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath,_
strValueName3, strValueEntry3
Next
Set objShell = CreateObject("WScript.Shel l")
objShell.Run "%COMSPEC% ipconfig /release",0,True
objShell.Run "%COMSPEC% ipconfig /renew",0,True
objShell.Run "%COMSPEC% ipconfig /flushdns",0,True
objShell.Run "%COMSPEC% ipconfig /registerdns",0,True
Set objShell = Nothing
it works fine on my machine but although it seems to run without error on a users machine it doesnt seem to make the required changes.
Do i need to specify credentials to ensure the user has rights to make the changes. Here is the script
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("S
For Each objItem in colItems
strnetsettingid = objItem.SettingID
Set objRegistry = _
GetObject("winmgmts:{imper
& strComputer & "\root\default:StdRegProv"
strKeyPath = "SYSTEM\CurrentControlSet\
strValueName1 = "Domain"
strValueName2 = "RegistrationEnabled"
strValueName3 = "RegisterAdapterName"
strValueEntry1 = "my.org"
strValueEntry2 = "1"
strValueEntry3 = "1"
objRegistry.SetStringValue
strValueName1, strValueEntry1
objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath,_
strValueName2, strValueEntry2
objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath,_
strValueName3, strValueEntry3
Next
Set objShell = CreateObject("WScript.Shel
objShell.Run "%COMSPEC% ipconfig /release",0,True
objShell.Run "%COMSPEC% ipconfig /renew",0,True
objShell.Run "%COMSPEC% ipconfig /flushdns",0,True
objShell.Run "%COMSPEC% ipconfig /registerdns",0,True
Set objShell = Nothing
Here is an article explaining .reg files:
http://support.microsoft.com/default.aspx?kbid=310516
and how to distribute them:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnw2kmag01/html/DistributingRegistryChanges.asp