Jump to content

Recommended Posts

Posted

Hi. I have 2 connections (not physical - ...Control panel/Connections) and need to switch between them every night.

Is there a way to do it programatically (desired without MouseClicks)?

Main problem - target OS is 7.

Thanks.

_____________________________________________________________________________

Posted

I found this code, but it allows to toggle Local connections only:(

_ToggleNetworkInterface('Intertelecom', 1)

;  $iFlag = 0 Disable network interface
;  $iFlag = 1 Enable network interface
Func _ToggleNetworkInterface($strNetwork, $iFlag = 1)
    Local $wbemFlagReturnImmediately = 0x10
    Local $wbemFlagForwardOnly = 0x20
    Local $strComputer = "localhost"

    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) Then
        For $objItem In $colItems        
            If $objItem.NetConnectionID = $strNetwork Then
                If $iFlag = 0 And $objItem.NetEnabled = True Then
                    $objItem.Disable
                ElseIf $iFlag = 1 And $objItem.NetEnabled = False Then
                    $objItem.Enable
                EndIf
                ExitLoop
            EndIf
        Next
    Else
        MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_NetworkAdapter")
    EndIf
EndFunc   ;==>_ToggleNetworkInterface

_____________________________________________________________________________

  • 2 weeks later...
Posted

Does anybody know how? Target language(Autoit, VB, C++, C#) not matter!

Just can't find no one example, that works under 7.

This is CLSID for Connections Folder

::{7007ACC7-3202-11D1-AAD2-00805FC1270E}

How can it be used in Autoit to get the final goal - I don't know:(

_____________________________________________________________________________

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...