先用devcon find =net pci\*查看所有Net ID,再用 devcon disable =net pci\ID (ID从第一个字符到&字符即可) devcon enable =net pci\ID 如ID为VEN_14E4&DEV_4320&SUBSYS_12F4103C&REV_03\4&139E449D&0&18F0,只需写VEN_14E4即可. http://www.cnblogs.com/leeairw/archive/2005/06/03/167247.html?Pending=true#Post 如何在命令行模式下禁用或启用网卡 先看show interface 的结果, 然后选择你要disable的interface. 注意带空格的名称需要用引号. netsh interface show interface Admin State State Type Interface Name ------------------------------------------------------------------------- Enabled Unreachable Dedicated Local Area Connection 2 Enabled Unreachable Dedicated Local Area Connection Enabled Unreachable Internal Internal Enabled Unreachable Loopback Loopback netsh interface set interface name="Local Area Connection" admin=DISABLED 经测试发现有错误! https:///showthread.php?t=51805 NETSH在中文系统下不能set interface? 我在en win2k3里,可以直接使用: netsh int set interface name=%localnic% admin=enabled/disabled 来开关网络连接。 但在winxp cn sp2里,竟发现这个命令失效,总是报: 引用 C:\temp>netsh int set interface name="本地连接" admin=enabled 没有指定一个或多个关键性参数 此命令提供的语法不正确。请查看帮助以获取正确的语法信息。 用法 set interface [name = ] IfName [ [admin = ] ENABLED|DISABLED [connect = ] CONNECTED|DISCONNECTED [newname = ] NewName ] 设置接口参数。 IfName - 接口名称 admin - 接口是否被启用 (仅用于非 LAN)。 connect - 是否连接接口 (仅用于非 LAN)。 newname - 接口的新名称 (仅用于非 LAN)。 注意: - 除名称外,还必须至少指定一个选项。 - 如果 connect = CONNECTED 被指定,那么接口被自动 启用,甚至在 admin = DISABLED 选项被指定时也是如 此。 1, 谁使用en winxp,试试这个命令是否只是对中文系统失效? 2, 有什么好用的替换命令行,达到同样的效果? 英文xp下也有这个问题, 在下面的帖子里已作初探: https:///showthread.php?t=52660 https:///showthread.php?t=52660 重大发现,XP里的netsh 存在严重缺陷及修补 -------------------------------------------------------------------------------- 我之前在这里提出过这个问题: https:///showthread.php?t=51805 但似乎没有引起重视。 在cn xp sp2里,用netsh 去disable,enable某interface 总是报错。 原本以为是“汉化”的问题,后来,让安装en xp sp2的朋友试了一下,一样不成。 但这个命令在win2k3里是好好的。 今天研究了一下,发现,问题就出在ifmon.dll这个文件身上。 用win2k3的 ifmon.dll 替换 xp里的同名文件, netsh int set interface 命令立即就有效了。 奇怪的是,win2k3里,ifmon.dll和netsh.exe的文件日期都是2002,但在xp里是2005,怎么新反不如旧呢? 另一个奇怪的是,xp的netsh 比 2k3的netsh 速度慢了一倍,不知又是搞了什么。所以,我也把netsh.exe也替换了。 大家去测试一下,这样替换,会否还有其他问题,我暂时试了所有的tcp/ip切换脚本,一切都正常。 替换前,建议备份一下xp的原文件,有需要时就换回去。 所上传文件 2k3.zip (63.2 KB, 4 次点击) https:///attachment.php?attachmentid=108352 这个自然。 你有没有注意到,无论英文版还是中文版,在Windows xp, 对set interface的说明,和Windows 2003下是不同的? 代码 (双击代码复制到粘贴板)用法 set interface [name = ] IfName [ [admin = ] ENABLED|DISABLED [connect = ] CONNECTED|DISCONNECTED [newname = ] NewName ] 设置接口参数。 IfName - 接口名称 admin - 接口是否被启用 (仅用于非 LAN)。 connect - 是否连接接口 (仅用于非 LAN)。 newname - 接口的新名称 (仅用于非 LAN)。 xp里,有那个“仅用于非 LAN”(non-LAN only)的说明,而2003里面没有。 xp里的netsh的确是少了点功能,或者说是m$给diable了,为何不得而知,估计和winxp里,微软为安全考量,尝试调整内部结构有关。 2003里,有了别的实现,又恢复enable了这个功能。 事实上,xp里同样的功能是通过DDK里的一个工具,DevCon.exe来实现的, m$的解释是,禁止网络连接就是禁止对应的网卡,DevCon是用于管理物理网卡或物理接口的。 netsh是用来管理逻辑接口的。 由此也可看出2003是作了变化的,允许逻辑接口直接映射物理接口了。 再补充一下,除了通过netsh或DevCon从逻辑或物理接口上Enable/Disable网络连接之外,还有一个可以通过模拟界面点击动作的方式,管理网络连接。 下面的VBS教本,是某位MVP N年以前公布的大作,的确让人耳目一新。 代码 (双击代码复制到粘贴板)Const ssfCONTROLS = 3 sConnectionName = "Local Area Connection" ‘ 修改名称,管理不同的网络连接 sEnableVerb = "En&able" sDisableVerb = "Disa&ble" Set shellApp = createobject("shell.application"screen.width/2)this.width=screen.width/2" vspace=2 border=0> Set oControlPanel = shellApp.Namespace(ssfCONTROLS) Set oNetConnections = nothing For each folderitem in oControlPanel.items If folderitem.name = "Network and Dial-up Connections" Then Set oNetConnections = folderitem.getfolder: exit For End If Next If oNetConnections is nothing Then msgbox "Couldn‘t find ‘Network and Dial-up Connections‘ folder" Wscript.quit End If Set oLanConnection = nothing For each folderitem in oNetConnections.items If lcase(folderitem.name) = lcase(sConnectionName) Then Set oLanConnection = folderitem: exit For End If Next If oLanConnection is nothing Then msgbox "Couldn‘t find ‘" & sConnectionName & "‘ item" Wscript.quit End If bEnabled = true Set oEnableVerb = nothing Set oDisableVerb = nothing s = "Verbs: " & vbcrlf For each verb in oLanConnection.verbs s = s & vbcrlf & verb.name If verb.name = sEnableVerb Then Set oEnableVerb = verb bEnabled = false End If If verb.name = sDisableVerb Then Set oDisableVerb = verb End If Next ‘debugging displays left just in case... ‘ ‘msgbox s ‘: Wscript.quit ‘msgbox "Enabled: " & bEnabled ‘: Wscript.quit ‘not sure why, but invokeverb always seemed to work ‘For enable but not disable. ‘ ‘saving a reference to the appropriate verb object ‘and calling the DoIt method always seems to work. ‘ If bEnabled Then ‘ oLanConnection.invokeverb sDisableVerb oDisableVerb.DoIt else ‘ oLanConnection.invokeverb sEnableVerb oEnableVerb.DoIt End If ‘adjust the sleep duration below as needed... ‘ ‘If you let the oLanConnection go out of scope ‘and be destroyed too soon, the action of the verb ‘may not take... ‘ Wscript.sleep 1000 这个脚本我上年就用过了,当时是在WINXP HOME里使用的,经常出现disable后,不能enable的情况。 比不上netsh整齐划一。微软在XP里禁了NETSH的功能,set interface 说是仅用于非LAN,不知是什么意思?即使是用于无线网卡(算非LAN吧?),同样不成。 DEVCON ,我在XP里找不到这个命令。 DevCon在Windows的DDK里面, 到这里下载吧: _http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272 DevCon的例子: _http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ddtools/hh/ddtools/DevCon_d48ee25b-021f-45f8-94be-a66f8db40fdf.xml.asp 那个教本,也就是说它比较另类而已。 使用当然不若netsh或DevCon啦。 |
|