Reprinted to http://community.csdn.net/Expert/topic/4881/4881882.xml
Const ssfcontrols = 3
Sconnectionname = "Local Connection" can be changed to the name of the connection to be controlled, such as "wireless network connection ".
Senableverb = "enable (& )"
Sdisableverb = "disabled (& B)" 'xp system should be "disabled (& 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
End if
Next
If onetconnections is nothing then
Msgbox "network connection folder not found"
Wscript. Quit
End if
Set olanconnection = nothing
For each folderitem in onetconnections. Items
If lcase (folderitem. Name) = lcase (sconnectionname) then
Set olanconnection = folderitem: exit
End if
Next
If olanconnection is nothing then
Msgbox "not found '" & 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
'Destgging 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