手机
当前位置:查字典教程网 >脚本专栏 >vbs >本地连接禁用/启用批处理脚本
本地连接禁用/启用批处理脚本
摘要:复制代码代码如下:ConstssfCONTROLS=3sConnectionName="本地连接"'可改成需要控制的连接名称,如"无线网络连...

复制代码 代码如下:

ConstssfCONTROLS=3

sConnectionName="本地连接"'可改成需要控制的连接名称,如"无线网络连接"等

sEnableVerb="启用(&A)"

sDisableVerb="禁用(&B)"'XP系统中应为"停用(&B)"

setshellApp=createobject("shell.application")

setoControlPanel=shellApp.Namespace(ssfCONTROLS)

setoNetConnections=nothing

foreachfolderiteminoControlPanel.items

iffolderitem.name="网络连接"then

setoNetConnections=folderitem.getfolder:exitfor

endif

next

ifoNetConnectionsisnothingthen

msgbox"未找到网络连接文件夹"

wscript.quit

endif

setoLanConnection=nothing

foreachfolderiteminoNetConnections.items

iflcase(folderitem.name)=lcase(sConnectionName)then

setoLanConnection=folderitem:exitfor

endif

next

ifoLanConnectionisnothingthen

msgbox"未找到'"&sConnectionName&"'item"

wscript.quit

endif

bEnabled=true

setoEnableVerb=nothing

setoDisableVerb=nothing

s="Verbs:"&vbcrlf

foreachverbinoLanConnection.verbs

s=s&vbcrlf&verb.name

ifverb.name=sEnableVerbthen

setoEnableVerb=verb

bEnabled=false

endif

ifverb.name=sDisableVerbthen

setoDisableVerb=verb

endif

next

'debuggingdisplaysleftjustincase...

'

'msgboxs':wscript.quit

'msgbox"Enabled:"&bEnabled':wscript.quit

'notsurewhy,butinvokeverbalwaysseemedtowork

'forenablebutnotdisable.

'

'savingareferencetotheappropriateverbobject

'andcallingtheDoItmethodalwaysseemstowork.

'

ifbEnabledthen

'oLanConnection.invokeverbsDisableVerb

oDisableVerb.DoIt

else

'oLanConnection.invokeverbsEnableVerb

oEnableVerb.DoIt

endif

'adjustthesleepdurationbelowasneeded...

'

'ifyoulettheoLanConnectiongooutofscope

'andbedestroyedtoosoon,theactionoftheverb

'maynottake...

'

wscript.sleep400

【本地连接禁用/启用批处理脚本】相关文章:

打开QQ并且让它自己输入用户名和密码的vbs脚本

自己写的一个定时关机或重启的vbs脚本

用vbs实现自动检查代理是否可用,并自动设置IE代理的脚本

用vbs实现注册表开关的脚本

用vbs实现本地连接禁用/启用脚本代码

注册表-批处理-VBS之间的相互结合应用第1/2页

文本文件分割脚本(VBS)

用vbs实现修改dns的网关脚本

用vbs实现zip功能的脚本

Windows管理脚本学习

精品推荐
分类导航