vbs脚本 实现无线网络连接与本地连接的网卡禁用启用完美切换(优化版)(VBS scripts enable wireless network connections and local connections to the network card. Disable enabling perfect sw..
vbs脚本 实现无线网络连接与本地连接的网卡禁用启用完美切换
(优化版)(VBS scripts enable wireless network connections and local connections to the network card. Disable enabling
perfect switching (optimized version))
The VBS script implements the "wireless network connection" and the "local connection" network card to disable enabling perfect switching (optimized version)
It was possible to use only one VBS, but with only one VBS, it was a bit of a hassle to select a local connection or a wireless connection every time the user chooses.
Therefore, local connections and wireless connections are enabled, placed in different VBS scripts, and run one of the scripts as needed.
The following result is "enable Wireless.vbs" code of communism
'----------------- started developing wireless network related services
Set vbs=CreateObject ("Wscript.Shell")
'***************Wireless Zero Configuration
Vbs.Run "SC, config, WZCSVC, start=, demand""
Vbs.Run "SC start WZCSVC""
'***************Atheros configuration services
Vbs.Run "SC, config, ACS, start=, demand""
Vbs.Run "SC start ACS""
Wscript.sleep 1000
SEnableConnectionName = wireless network connection"
SDisableConnectionName = local connection"
Const ssfCONTROLS = 3
SEnableVerb = "enable" (&A)"
SDisableVerb = disable (&B)"
Set shellApp = CreateObject ("shell.application")
Set oControlPanel = shellApp.Namespace (ssfCONTROLS)
Set oNetConnections = nothing
For, each, folderitem, in, oControlPanel.items
If folderitem.name = "network connection" Then
Set oNetConnections = folderitem.getfolder:, exit, for
End if
Next
If, oNetConnections, is, nothing, then
Msgbox "no network and dial up Connections folder found"
Wscript.quit
End if
'----------------- stopped developing connection
Set oLanConnection = nothing
For, each, folderitem, in, oNetConnections.items
If lcase (folderitem.name) = lcase (sDisableConnectionName) then
Set oLanConnection = folderitem:, exit, for
End if
Next
If, oLanConnection, is, nothing, then
Msgbox "not found" - & sDisableConnectionName & item"
Else
Set oEnableVerb = nothing
Set oDisableVerb = nothing
For, each, verb, in, oLanConnection.verbs
If verb.name = sDisableVerb then
Set oDisableVerb = verb
Exit For
End if
Next
If not (oDisableVerb, is, nothing) then
ODisableVerb.DoIt
End if
End If
'----------------- developing to enable the connection
Set oLanConnection = nothing
For, each, folderitem, in, oNetConnections.items
If lcase (folderitem.name) = lcase (sEnableConnectionName)
then
Set oLanConnection = folderitem:, exit, for
End if
Next
If, oLanConnection, is, nothing, then
Msgbox "not found" - & sEnableConnectionName & item"
Else
Set oEnableVerb = nothing
Set oDisableVerb = nothing
For, each, verb, in, oLanConnection.verbs
If verb.name = sEnableVerb then
Set oEnableVerb = verb
Exit For
End if
Next
If not (oEnableVerb, is, nothing) then
OEnableVerb.DoIt
最后如果
最后如果
wscript.sleep 1000
********以下是”启用本地连接.vbs”的代码********
senableconnectionname =“本地连接”
sdisableconnectionname =“无线网络连接”
const ssfcontrols = 3
senableverb =“启用(&)”
sdisableverb =“停用(& B)”
集shellapp = CreateObject(“壳”中的应用)
集ocontrolpanel = shellapp命名空间(ssfcontrols)。
集onetconnections =没有
每个folderitem在ocontrolpanel.items
如果folderitem.name =“网络连接”然后
集onetconnections = folderitem.getfolder:退出
最后如果
下一个
如果onetconnections是没有然后
本未找到网络和拨号连接文件夹”
wscript.quit
最后如果
“-----------------停用连接-----------------
集olanconnection =没有
每个folderitem在onetconnections.items
如果1例(folderitem。名字)= 1例(sdisableconnectionname)然后
集olanconnection = folderitem:退出
最后如果
下一个
如果olanconnection是没有然后
本未找到”与sdisableconnectionname &“'项目”
其他的
集oenableverb =没有
集odisableverb =没有
每个动词在olanconnection.verbs
如果verb.name = sdisableverb然后
集odisableverb =动词
退出
最后如果
下一个
如果不是(odisableverb什么)然后
odisableverb.doit
最后如果
最后如果
“-----------------启用连接-----------------
集olanconnection =没有
每个folderitem在onetconnections.items
如果1例(folderitem。名字)= 1例(senableconnectionname)然后
集olanconnection = folderitem:退出
最后如果
下一个
如果olanconnection是没有然后
本未找到”与senableconnectionname &“'项目”
其他的
集oenableverb =没有
集odisableverb =没有
每个动词在olanconnection.verbs
如果verb.name = senableverb然后
集oenableverb =动词
退出
最后如果
下一个
如果不是(oenableverb什么)然后
oenableverb.doit
最后如果
最后如果
wscript.sleep 800
“-----------------停止无线网络相关服务-----------------
设置VBS = CreateObject(“wscript。壳”)
“***************无线零配置
VBS。运行“SC停止WZCSVC”
VBS。运行“sc config WZCSVC开始=禁用”
“*************** Atheros配置服务
VBS。运行“SC阻止ACS”
VBS。运行“SC配置ACS开始=禁用”