How to programmatically enable/disable network interfaces? (Windows XP)

前端 未结 7 1977
一生所求
一生所求 2020-12-02 19:23

I need to enable/disable completely network interfaces from a script in Windows XP. I\'m looking for a python solution, but any general way (eg WMI, some command-line à la n

7条回答
  •  伪装坚强ぢ
    2020-12-02 20:18

    this is VB.Net

    Dim objectQuery As New ObjectQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionId IS NOT NULL")
             Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
             Dim os As ManagementObject
             Dim moColl As ManagementObjectCollection = searcher.Get()
             Dim _list As String = ""
             For Each os In moColl
                 Console.WriteLine(os("NetConnectionId"))
             Next os
    

    That will get all the interfaces on you computer. Then you can do netsh to disable it.

    netsh interface set interface DISABLED

提交回复
热议问题