Jump to content

Switch between connections


Recommended Posts

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.

_____________________________________________________________________________

Link to comment
Share on other sites

Do you mean different named configs for the network connection? Maybe NETCFG.EXE?

Not sure what "Control panel/Connections" means.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

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

_____________________________________________________________________________

Link to comment
Share on other sites

  • 2 weeks later...

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:(

_____________________________________________________________________________

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...