Code Comments
Programming Forum and web based access to our favorite programming groups.On a PC with more than one NIC installed. We only want to
change the address on one card. How can we point the
script to just one card? The card in question is a Dlink
NIC pcmcia card.
'Begin script
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer_
& "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration_
where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.xxx")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.xxx")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress,_
strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway,_
strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next
'End Script
Thanks!!
-Steve
Post Follow-up to this messagestev379 wrote:
> On a PC with more than one NIC installed. We only want to
> change the address on one card. How can we point the
> script to just one card? The card in question is a Dlink
> NIC pcmcia card.
>
> (snip code)
Hi
In the For Each loop, test on the objNetAdapter.Description property.
For my computer, I would need to do like this to hit my 3Com adapter:
If LCase(objNetAdapter.Description) = _
LCase("3Com 10/100 Mini PCI Ethernet Adapter") Then
' do something here
End If
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/sc...er/default.mspx
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.