校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > 用vbs實現本地連接禁用/啟用腳本代碼

用vbs實現本地連接禁用/啟用腳本代碼

熱門標簽:外呼線路中繼線是什么 深圳外呼系統收費 合肥高德地圖標注 怎么看地圖標注 廣州ai電銷機器人一般多少錢 百度地圖標注是什么意思 外呼系統telrobot 外呼系統免費招代理 拉薩外呼系統業務
轉載至 http://community.csdn.net/Expert/topic/4881/4881882.xml

復制代碼 代碼如下:

Const ssfCONTROLS = 3 

sConnectionName = "本地連接"  '可改成需要控制的連接名稱,如"無線網絡連接"等 

sEnableVerb = "啟用(A)" 
sDisableVerb = "禁用(B)"   'XP系統中應為 "停用(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 

'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 400 
您可能感興趣的文章:
  • 用vbs實現禁用服務
  • vbscript禁用 啟用fso的方法
  • 使用 iisext.vbs 禁用 Web 服務擴展的方法
  • bat生成vbs通過注冊表禁用或啟用USB端口的代碼
  • 使用VBS禁用、啟動USB存儲設備
  • VB實現禁用任務管理器的方法

標簽:周口 廣安 玉林 嘉興 漳州 延安 六安 臺灣

巨人網絡通訊聲明:本文標題《用vbs實現本地連接禁用/啟用腳本代碼》,本文關鍵詞  用,vbs,實現,本地,連接,禁用,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《用vbs實現本地連接禁用/啟用腳本代碼》相關的同類信息!
  • 本頁收集關于用vbs實現本地連接禁用/啟用腳本代碼的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 朝阳区| 芜湖县| 革吉县| 涞水县| 曲阜市| 友谊县| 罗甸县| 彰化县| 塔河县| 胶州市| 阳曲县| 八宿县| 吴桥县| 忻州市| 广灵县| 沅陵县| 石门县| 松阳县| 夏邑县| 元氏县| 祁门县| 桂阳县| 池州市| 临沧市| 平度市| 汾西县| 鞍山市| 金坛市| 汉中市| 临沧市| 和静县| 永仁县| 孟州市| 林甸县| 方山县| 和静县| 镇沅| 浙江省| 门源| 康平县| 三明市|