Login   /   Register

Disabling a network adapter

Rate this article
     1 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 5
Loading ... Loading ...
July 20th, 2008 by Yaron Assa

Yanir Goren was kind enough to share the following QTip, which allows you to completely disable a network adapter:

Dim i 
Dim adptCount , objDrvs ,sMACAddress
 
i = 0
sMACAddress = "Enter MAC Address Here" 'The adapter’s Mac Address
 
'****  create instance of network adapters***
set objDrvs = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapter")
adptCount = objDrvs.count '**** object contain all network adapters
 
'*** search for object with required macaddress***   
Do
  If strcomp(ucase(objDrvs.itemindex(i).properties_.item("MACAddress").value) , ucase(sMACAddress)) =0 Then
 '*** enable/disable adapter***
   objDrvs.itemindex(i).disable/enable
   Exit do         
  End If
 
  i = i +1
  loop until (i = adptCount)
End Function

Posted in Networking

Leave a Reply

You must be logged in to post a comment.

This article was viewed 650 times