管理网卡vbs脚本
程序员文章站
2022-04-29 09:14:14
'dislan.vbs 'usage: cscript ...
'dislan.vbs
'usage: cscript /nologo dislan.vbs
const ssfcontrols = 3
sconnectionname = "本地连接"
senableverb = "启用(&a)"
sdisableverb = "禁用(&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
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
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
if benabled then
odisableverb.doit
else
oenableverb.doit
end if
wscript.sleep 1000
'usage: cscript /nologo dislan.vbs
const ssfcontrols = 3
sconnectionname = "本地连接"
senableverb = "启用(&a)"
sdisableverb = "禁用(&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
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
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
if benabled then
odisableverb.doit
else
oenableverb.doit
end if
wscript.sleep 1000