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

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

问题描述

我需要通过 Windows XP 中的脚本完全启用/禁用网络接口.我正在寻找一个 python 解决方案,但任何通用方法(例如 WMI、一些命令行 à la 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 接口用法 set interface [name = ] IfName[ [管理员 = ] 启用|禁用[connect = ] 已连接|已断开[新名称 = ] 新名称 ]

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

尝试在外括号内包含所有内容:netsh interface set interface name="thename" admin=disabled 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天全站免登陆