Networking Forums

Networking Forums > Computer Networking > Windows Networking > Disabling/enabling network adapter from script

Reply
Thread Tools Display Modes

Disabling/enabling network adapter from script

 
 
=?Utf-8?B?S2VubnlC?=
Guest
Posts: n/a

 
      12-01-2004, 02:45 PM
I need to change the ip address on an adapter programmatically but the only
way i can figure out how to do it is to modify the ip address in the
registry, disable the network adapter, and then reenable it. Does anyone know
how I might do that? I've searched MSDN and CodeGuru among other places, and
there are lots of hints on adding an ip address, but none on deleting or
modifying it.

Thanks.....kennyb
 
Reply With Quote
 
 
 
 
Mark-Allen Perry
Guest
Posts: n/a

 
      12-01-2004, 02:55 PM
How about:

strComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set colNetAdapters = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")strIPAddress = Array("192.168.1.141")strSubnetMask = Array("255.255.255.0")strGateway = Array("192.168.1.100")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 IfNext
Check: http://www.microsoft.com/technet/scr...r/default.mspx for almost everything under scripting.

Hope this helps.

--

Always try the MS KB first before posting.
MS KB: http://support.microsoft.com/default...;EN-US;KBHOWTO
And the answer could have already been posted, so try searching this and other newsgroups first.
----
Mark-Allen Perry
ALPHA Systems
Marly, Switzerland
mark-allen_AT_mvps_DOT_org

"KennyB" <(E-Mail Removed)> wrote in message news:9BAEA2EC-9B4A-4E84-861F-(E-Mail Removed)...
I need to change the ip address on an adapter programmatically but the only
way i can figure out how to do it is to modify the ip address in the
registry, disable the network adapter, and then reenable it. Does anyone know
how I might do that? I've searched MSDN and CodeGuru among other places, and
there are lots of hints on adding an ip address, but none on deleting or
modifying it.

Thanks.....kennyb
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
netgear wireless adapter disabling usb ports! fluffypinklaa@sky.com Wireless Internet 4 04-06-2007 05:24 PM
Enabling\Disabling a Wireless Nic with a restricted account Bob Wireless Networks 3 12-14-2006 06:26 PM
Problems enabling/disabling Proxy Settings in IE gw1984 Windows Networking 4 03-31-2006 02:32 PM
Linksys WUSB11 adapter disabling WRT54G router? Rich Wales Wireless Internet 5 02-14-2005 03:20 AM
Network Adapter keeps disabling / disconnecting Ugo Windows Networking 0 04-30-2004 12:02 AM



1 2 3 4 5 6 7 8 9 10 11