首页脚本本地连接禁用/启用批处理脚本

本地连接禁用/启用批处理脚本

时间2024-02-11 06:41:03发布访客分类脚本浏览924
导读:收集整理的这篇文章主要介绍了本地连接禁用/启用批处理脚本,觉得挺不错的,现在分享给大家,也给大家做个参考。 复制代码 代码如下:Const ssfcONTROLS = 3 sConne...
收集整理的这篇文章主要介绍了本地连接禁用/启用批处理脚本,觉得挺不错的,现在分享给大家,也给大家做个参考。

复制代码 代码如下:
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 

您可能感兴趣的文章:
  • BAT 批处理脚本教程(详细篇补充)
  • Windows server利用批处理脚本判断端口启动tomcat的方法
  • Windows下编写批处理脚本来启动和重置Oracle数据库
  • Windows下bat批处理脚本使用telnet批量检测远程端口小记
  • 实现android应用程序自动化测试的批处理脚本
  • ip地址切换批处理脚本分享
  • 批量安装windows补丁的批处理脚本
  • QQ多帐号自动登录批处理脚本
  • DOS批处理脚本语言简介与详细说明
  • Windows注册表中修改UAC(用户账号控制)及批处理脚本

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: 本地连接禁用/启用批处理脚本
本文地址: https://pptw.com/jishu/609452.html
vue3的父传子问题(单项数据流) 右键发送(sendto),创建快捷方式到自定义的位置 的vbs

游客 回复需填写必要信息