Disable and Enable Network Adapter from vb.net
  • Imports System.Management

    Dim managementClass As New ManagementClass("Win32_NetworkAdapter")
    Dim mgmtObjectColl As ManagementObjectCollection = managementClass.GetInstances()

    Dim myObject As ManagementObject = Nothing
    For Each mgmtObject As ManagementObject In mgmtObjectColl

    If mgmtObject("NetConnectionID") IsNot Nothing AndAlso mgmtObject("NetConnectionID").Equals("Local Area Connection") Then
    myObject = mgmtObject

    Dim result As Object = mgmtObject.InvokeMethod("Disable", Nothing)
    End If


    ' Write your code here which will execute before enable network interface

    Dim result3 As Object = myObject.InvokeMethod("Enable", Nothing)

    You have to 'Add Reference' (right click over project, from menu select add reference). Then go select the System.Management class and click OK.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

    Optimum Creative