IT 專業人員的技術資源 > 論壇首頁 > Windows Client 論壇 > Windows Client 作業系統 (Windows Vista 的問題請移駕Windows Vista 專區 ) > 區域連線快速斷線方法?
區域連線快速斷線方法? 
- 我的電腦是用windows xp pro sp2的
現在我造了一個捷徑, 當區域連線停用了的時候,只要按一下就可以自動連線
但是,要斷線時,卻要按一下右下角的"區域連線"-->停用 才可以。
想問一問有沒有方法可以像"捷徑"一般,按一下就斷線呢?
如果捷徑做不到,不知道dos command 有沒有方法可以做到呢?(生成xxx.bat)
謝謝解答問題!
解答
-
HI:
大致上有3種方法
1.
使用devcon工具去停用或啟用網路卡,請參考
http://alexchuo.blogspot.com/2004/10/blog-post_13.html
2.
如果你是Windows 2003,可以用下列指令
停用
netsh interface set interface "區域連線" disabled
啟用
netsh interface set interface "區域連線" enabled
區域連線這個名稱改成你要停用或啟用的連線名稱,可以在控制台中的網路連線找到
XP的話,要從Windows 2003拿ifmon.dll覆蓋XP的檔案
3.
用以下vb script,把以下內容存成XXX.vbs,點2下執行,會把啟用狀態改為停用,或者停用改為啟用
其中幾個參數可能要根據電腦作修改
sConnectionName = "區域連線"
區域連線這個名稱改成你要停用或啟用的連線名稱,可以在控制台中的網路連線找到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 "Couldn't find '網路連線' 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 ss = 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 謝謝- 已標示為解答kcshining2009年3月25日 上午 02:49
所有回覆
-
HI:
大致上有3種方法
1.
使用devcon工具去停用或啟用網路卡,請參考
http://alexchuo.blogspot.com/2004/10/blog-post_13.html
2.
如果你是Windows 2003,可以用下列指令
停用
netsh interface set interface "區域連線" disabled
啟用
netsh interface set interface "區域連線" enabled
區域連線這個名稱改成你要停用或啟用的連線名稱,可以在控制台中的網路連線找到
XP的話,要從Windows 2003拿ifmon.dll覆蓋XP的檔案
3.
用以下vb script,把以下內容存成XXX.vbs,點2下執行,會把啟用狀態改為停用,或者停用改為啟用
其中幾個參數可能要根據電腦作修改
sConnectionName = "區域連線"
區域連線這個名稱改成你要停用或啟用的連線名稱,可以在控制台中的網路連線找到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 "Couldn't find '網路連線' 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 ss = 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 謝謝- 已標示為解答kcshining2009年3月25日 上午 02:49
-
那段vb script十分有效,
謝謝你的解答!
沒有留言:
張貼留言