如何以编程方式启用/禁用网络接口? (Windows XP) [英] How to programmatically enable/disable network interfaces? (Windows XP)

查看:68
本文介绍了如何以编程方式启用/禁用网络接口? (Windows XP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从Windows XP中的脚本启用/禁用完全网络接口.我正在寻找python解决方案,但是可以使用任何通用方式(例如WMI,一些命令行ànetsh,一些Windows调用),并将对其进行调整.谢谢.

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 netsh, some windows call) is welcome and will be adjusted. Thanks.

推荐答案

使用netsh界面 用法集接口[name =] IfName [[admin =]启用|禁用 [connect =] CONNECTED | DISCONNECTED [newname =] NewName]

Using the netsh interface Usage set interface [name = ] IfName [ [admin = ] ENABLED|DISABLED [connect = ] CONNECTED|DISCONNECTED [newname = ] NewName ]

尝试将所有内容包括在外括号中: netsh接口设置接口名称="thename" admin =已禁用connect = DISCONNECTED newname ="thename"

Try including everything inside the outer brackets: netsh interface set interface name="thename" admin=disabled connect=DISCONNECTED newname="thename"

另请参见此MS KB页面: http://support.microsoft.com/kb/262265/ 您可以遵循他们的任何建议. 要禁用适配器,您将需要确定引用硬件设备的方法.如果计算机上没有多个具有相同名称的适配器,则可以取消接口的描述"(或PCI ID效果很好).之后,使用devcon(禁用). Devcon是设备管理器的附加控制台界面.

See also this MS KB page: http://support.microsoft.com/kb/262265/ You could follow either of their suggestions. For disabling the adapter, you will need to determine a way to reference the hardware device. If there will not be multiple adapters with the same name on the computer, you could possibly go off of the Description for the interface (or PCI ID works well). After that, using devcon (disable|enable). Devcon is an add-on console interface for the Device Manager.

这篇关于如何以编程方式启用/禁用网络接口? (Windows XP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆