Jump to content
Sign in to follow this  
GodlessSinner

Switch between connections

Recommended Posts

GodlessSinner

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.


_____________________________________________________________________________

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
foolet

I think he means like wired/wireless? Not sure...

Share this post


Link to post
Share on other sites
GodlessSinner

netcfg.exe doesn't work. (win 7 64-bit)

post-38636-12778482062154_thumb.jpg

Edited by GodlessSinner

_____________________________________________________________________________

Share this post


Link to post
Share on other sites
GodlessSinner

Does anybody know?


_____________________________________________________________________________

Share this post


Link to post
Share on other sites
GodlessSinner

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

_____________________________________________________________________________

Share this post


Link to post
Share on other sites
GodlessSinner

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


_____________________________________________________________________________

Share this post


Link to post
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
Sign in to follow this  

×