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(sDisableConnectionName) then
set oLanConnection = folderitem: exit for
end if
next
if oLanConnection is nothing then
msgbox "未找到 '" & 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
'---------------------------启用连接---------------------------------
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 "未找到 '" & 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
end if
end If
wscript.sleep 800