Hmm. I"m in training all week, and I feel so powerless without my tools. If I remember correctly, then what you need to do is find the W2k key where the NICs are enumerated and retrieve a list of GUIDs, then head back to the key below and use the information you just got to find and change the correct keys. Here's an example, but it's really old code, and I hadn't heard about some of the fundamentals like use strict yet, so it's a little ugly. (You'll probably have to fix the wrapping, too) This just gets the values, but it shouldn't be too hard to change the values. I don't know if the changes will take effect, though, until the machine is rebooted if you do it this way. NT4 actually does it differently in the registry.
sub getIPInfo{ #### WINDOWS 2000 #### if($Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/CurrentVersion"} eq "5.0"){ $adapterRoot = $Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/NetworkCards/"}; $ipRoot = $Registry->{"//client/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/ Tcpip/Parameters/Interfaces/"}; @adapterKeys = keys %{$adapterRoot}; foreach $key(@adapterKeys){ $name = $adapterRoot->{$key}->{'ServiceName'}; $service = $adapterRoot->{$key}->{'ServiceName'}; $nics->{$name}{'Description'} = $adapterRoot->{$key}->{'Description'}; $nics->{$name}{'ServiceName'} = $adapterRoot->{$key}->{'ServiceName'}; $nics->{$name}{'Domain'} = $ipRoot->{"$servicename/Domain"}; $nics->{$name}{'DNS'} = $ipRoot->{"$servicename/NameServer"}; if($ipRoot->{"$service/EnableDHCP"} eq "0x00000000"){ $nics->{$name}{'IPAddress'} = $ipRoot->{"$service/IPAddress"}; $nics->{$name}{'Subnet'} = $ipRoot->{"$service/SubnetMask"}; $nics->{$name}{'DHCPEnabled'} = "No"; $nics->{$name}{'Gateway'} = $ipRoot->{"$service/DefaultGateway"}; }elsif($ipRoot->{"$service/EnableDHCP"} eq "0x00000001"){ $nics->{$name}{'DHCPServer'} = $ipRoot->{"$service/DhcpServer"}; $nics->{$name}{'Subnet'} = $ipRoot->{"$service/DhcpSubnetMask"}; $nics->{$name}{'IPAddress'} = $ipRoot->{"$service/DhcpIPAddress"}; $nics->{$name}{'DHCPEnabled'} = "Yes"; $nics->{$name}{'Gateway'} = $ipRoot->{"$service/DhcpDefaultGateway"}; } } #### WINDOWS NT #### }elsif($Registry->{"//client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/CurrentVersion"} eq "4.0"){ $adapterRoot = $Registry->{"//$client/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/NetworkCards/"}; foreach $key(keys %{$adapterRoot}){ $name = $adapterRoot->{$key}->{'ServiceName'}; $service = $adapterRoot->{$key}->{'ServiceName'}; $nics->{$name}{'Description'} = $adapterRoot->{$key}->{'Description'}; $nics->{$name}{'ServiceName'} = $adapterRoot->{$key}->{'ServiceName'}; $ipRoot = $Registry->{"//client/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/$ service/Parameters/Tcpip/"}; if($ipRoot->{"EnableDHCP"} eq "0x00000000"){ $nics->{$name}{'IPAddress'} = $ipRoot->{"IPAddress"}; $nics->{$name}{'Subnet'} = $ipRoot->{"SubnetMask"}; $nics->{$name}{'DHCPEnabled'} = "No"; $nics->{$name}{'Gateway'} = $ipRoot->{"DefaultGateway"}; }elsif($ipRoot->{"EnableDHCP"} eq "0x00000001"){ $nics->{$name}{'DHCPServer'} = $ipRoot->{"DhcpServer"}; $nics->{$name}{'Subnet'} = $ipRoot->{"DhcpSubnetMask"}; $nics->{$name}{'IPAddress'} = $ipRoot->{"DhcpIPAddress"}; $nics->{$name}{'DHCPEnabled'} = "Yes"; $nics->{$name}{'Gateway'} = $ipRoot->{"DhcpDefaultGateway"}; }else{ print " DHCP status unknown on $name!\n"; } } } } -----Original Message----- From: Langa Kentane To: 'Tim Musson' Cc: Perl Beginners List Sent: 6/13/02 5:48 AM Subject: RE: Win32 reg? I tried that but unfortunately does not seem to have an effect on it. If you look further down the structure under interfaces that's where i should be setting the DNS server but unfortunately that will not be the same from computer to computer and I have not been able to find a way to determine that name & use it. If I can get a way to do that then it will solve my problems. Thanks > -----Original Message----- > From: Tim Musson [mailto:[EMAIL PROTECTED]] > Sent: 13 June 2002 02:22 PM > To: Langa Kentane > Subject: Re: Win32 reg? > > > Hey Langa, > > My MUA believes you used Internet Mail Service (5.5.2653.19) > to write the following on Thursday, June 13, 2002 at 1:34:28 AM. > > LK> Any ideas if there is a mod out there that I can use to > set Windows > LK> 2K DNS settings or is there any other way that I can set this? > > LK> I have been battling with this for a while and have not > been able to > LK> find a workable solution from MS Technet. The only way > that I could > LK> find entails using the Win2K resource kit and that also > means there > LK> have to be settings already there... Kind of like a search and > LK> replace operation which is not acceptable for this case > as I would > LK> like to change the setting without knowing the current setting. > > Does it work to just set (yes, I abbreviated a couple of the > folders...) > [HKLM\SYS\CurrentControlSet\Services\Tcpip\Parms\NameServer > > -- > [EMAIL PROTECTED] > MUA = TB! v1.60q (www.RitLabs.com/The_Bat) > Windows 2000 5.0.2195 (Service Pack 2) > Today is the tomorrow you worried about yesterday. > NOTICE: This message and any attachments are confidential and intended solely for the addressee. If you have received this message in error, please notify the sender at Nanoteq (Pty) Ltd immediately, telephone number +27 (0) 12 672 7000. Any unauthorised use, alteration or dissemination is prohibited. Nanoteq (Pty) Ltd accepts no liability whatsoever for any loss whether it be direct, indirect or consequential, arising from information made available and actions resulting there from. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]