主题 : 一键连接互换
级别: 四缕秋风
UID: 16354
精华: 0
发帖: 347
威望: 3623 点
无痕币: 26 WHB
贡献值: 0 点
在线时间: 69(时)
注册时间: 2008-03-08
最后登录: 2023-05-16

0 一键连接互换

连接互换.rar (1 K) 下载次数:2    单位的电脑有两块网卡,一块是局域网,一块接的宽带,工作时要用局域网,手动换连接很麻烦,有次在移动公司看到一个小程序挺好用的,也不知道是谁编的,反正给大家用的着的就用


红字部份改成自己连接的名字就行了




Const ssfCONTROLS = 3
sConnectionName = "本地连接"
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(sConnectionName) then
   set oLanConnection = folderitem: exit for
end if
next
if oLanConnection is nothing then
msgbox "未找到 '" & 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
if bEnabled then
oDisableVerb.DoIt
else
oEnableVerb.DoIt
end if
wscript.sleep 1000

sConnectionName = "网络连接"
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 "未找到 '" & 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
if bEnabled then
oDisableVerb.DoIt
else
oEnableVerb.DoIt
end if
wscript.sleep 1000


连接互换.rar (1 K) 下载次数:2
[ 此贴被浪子燕青在2008-11-28 15:34重新编辑 ]
Total 0.041939(s) query 3, Time now is:04-19 03:08, Gzip enabled 粤ICP备07514325号-1
Powered by PHPWind v7.3.2 Certificate Code © 2003-13 秋无痕论坛