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

前端 未结 7 2049
一生所求
一生所求 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:25

    So far I've found the following Python solution:

    >>> import wmi; c=wmi.WMI()
    >>> o=c.query("select * from Win32_NetworkAdapter where NetConnectionID='wifi'")[0]
    >>> o.EnableDevice(1)
    (-2147217407,)
    

    which is translated, AFAIU, to the generic WMI error 0x80041001. Could be permissions.

提交回复
热议问题