![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-10 01:46 |
共 47,811 主题排行 / 349,897 发帖 / 今日 2 篇 / 48,255 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 求一个切换网卡的脚本 |
| 可打印版本 741 / 2 |
| 第1楼 lfplft | 发表于 2008-10-13 13:10 |
| 初级用户 发帖 13 积分 34 | |
|
求一个切换网卡的脚本 我有两块网卡,在网络连接里显示为“本地连接1”和“本地连接2“,平时只启用一个,现在想用一个脚本,实现以下功能:判断现在启用的是哪一个网卡,把它停用,并且启用另外一个,然后作出提示。BAT或VBS均可。恳请高手赐教!
|
|
| 第2楼 406317577 | 发表于 2008-10-13 16:36 |
| 初级用户 发帖 45 积分 98 | |
|
手动禁止一个不就行了
|
|
| 第3楼 hackate | 发表于 2008-10-13 18:17 |
| 中级用户 发帖 125 积分 228 | |
|
这有一个VBS批处理文件,会停用一个网卡,然后启用一个网卡,你可以用这个
里面前两行定义网络的名称,前一个sEnableConnectionName是要启用的网络名,第二行那个是停用的网络名称,这个可以从控制面板-网络连接里面看到; 你只要将这个下面的内容复制下来,在记事本中粘贴出来,保存为VBS文件(如:切换网卡.vbs),就可以执行了 下面是VBS文件内容: sEnableConnectionName = "无线网络连接" sDisableConnectionName = "本地连接" Const ssfCONTROLS = 3 sEnableVerb = "启用(&A)" sDisableVerb = "停用(&B)" set shellApp = createobject("shell.application") set oControlPanel = shellApp.Namespace(ssfCONTROLS) set oNetConnections = nothing for each folderitem in oControlPanel.items If folderitem.name = "网络连接" Then Set oNetConnections = folderitem.getfolder: exit for end if next if oNetConnections is nothing then msgbox "未找到网络和拨号连接文件夹" wscript.quit end if '-----------------停用连接-------------------------- set oLanConnection = nothing for each folderitem in oNetConnections.items if lcase(folderitem.name) = lcase(sDisableConnectionName) then set oLanConnection = folderitem: exit for end if next if oLanConnection is nothing then msgbox "未找到 '" & sDisableConnectionName & "' item" Else Set oEnableVerb = nothing set oDisableVerb = nothing For each verb in oLanConnection.verbs if verb.name = sDisableVerb then set oDisableVerb = verb Exit For end if next If not (oDisableVerb is nothing) then oDisableVerb.DoIt end if end If '---------------------------启用连接--------------------------------- set oLanConnection = nothing for each folderitem in oNetConnections.items if lcase(folderitem.name) = lcase(sEnableConnectionName) then set oLanConnection = folderitem: exit for end if next if oLanConnection is nothing then msgbox "未找到 '" & sEnableConnectionName & "' item" Else Set oEnableVerb = nothing set oDisableVerb = nothing For each verb in oLanConnection.verbs If verb.name = sEnableVerb then set oEnableVerb = verb Exit For End if next If not (oEnableVerb is nothing) then oEnableVerb.DoIt end if end If wscript.sleep 800 |
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |