Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Change NIC's IP address
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

Report this thread to moderator Post Follow-up to this message
Old Post
stev379
07-30-04 08:55 PM


Re: Change NIC's IP address
stev379 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

Report this thread to moderator Post Follow-up to this message
Old Post
Torgeir Bakken \(MVP\)
07-30-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Windows Server Scripting archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:39 AM.

 

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.