Reprinted to Http://community.csdn.net/Expert/topic/4881/4881882.xml
Copy Code code as follows:
Const Ssfcontrols = 3
Sconnectionname = "Local Area Connection" can be changed to the name of the connection you want to control, such as "Wireless network Connection"
Senableverb = "enabled (&a)"
Sdisableverb = "Disabled (&b)" XP system should be "inactive (&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 connection folder 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 for
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
' Debugging displays left just ...
'
' 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 have the olanconnection go out of scope
' And be destroyed too soon, the action of the verb
' may not take ...
'
Wscript.Sleep 400