Jump to content
Sign in to follow this  
Guest trektaiwan

auto stop LAN

Recommended Posts

Guest trektaiwan

how to stop LAN in au3 ? thanks!!! :whistle::dance::dance:

Share this post


Link to post
Share on other sites
SumTingWong

how to stop LAN in au3 ? thanks!!! :dance:  :dance:  :(

<{POST_SNAPBACK}>

In your case, the most effective way would be to pull the plug! :whistle:

Share this post


Link to post
Share on other sites
Gigglestick

In your case, the most effective way would be to pull the plug!  :whistle:

LOL! :dance:

@trektaiwan

Hmmm... What OS? If this is Win2K/XP/2003, you could disable the adapter. I'm sure it could be done with a DLL call, but I don't know which DLL or function. Search the MSDN. Otherwise, you could bring up the network connections control panel, right-click the appropriate one, and hit disable.


My UDFs: ExitCodes

Share this post


Link to post
Share on other sites
Guest trektaiwan

LOL! :whistle:

@trektaiwan

Hmmm... What OS?  If this is Win2K/XP/2003, you could disable the adapter.  I'm sure it could be done with a DLL call, but I don't know which DLL or function.  Search the MSDN.  Otherwise, you could bring up the network connections control panel, right-click the appropriate one, and hit disable.

<{POST_SNAPBACK}>

maybe ok, but need to get mouse position and right click ...

my problem is how to auto stop and auto start LAN at sometime ...

Share this post


Link to post
Share on other sites
redndahead

I am sure doing "IPConfig /release" would do it. When you want it back run "IPConfig /renew"

red

Share this post


Link to post
Share on other sites
Gigglestick

I am sure doing "IPConfig /release" would do it.  When you want it back run "IPConfig /renew"

Good call!

Man, I can't believe my mind went in such a complicated direction over this! :whistle:


My UDFs: ExitCodes

Share this post


Link to post
Share on other sites
MSLx Fanboy

I believe that

netsh interface set interface "Local Area Connection" disable

would do it, else try admin = disable at the end

Source: netsh help documentation


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites
blindwig

I believe that

netsh interface set interface "Local Area Connection" disable

would do it, else try admin = disable at the end

Source:  netsh help documentation

<{POST_SNAPBACK}>

I think that only works for WAN connections, not LAN conections.

I've looked into this before, and I've never been able to find a way to enable and disable NICs programatically.

Share this post


Link to post
Share on other sites
SumTingWong

Here you go:

This method uses COM so it needs latest beta to work.

AutoItSetOption("MustDeclareVars", 1)

Dim $sEnableVerb = "En&able" 
Dim $sDisableVerb = "Disa&ble" 

; Usage example
_ToggleConnection("Local Area Connection", $sDisableVerb)

Func _ToggleConnection($sConnectionName, $sVerb)
    Local $oShell
    Local $oControlPanel
    Local $oFolderItem
    Local $oNetConnections
    Local $oConnectionItem
    Local $oLanConnection
    Local $oVerbItem
    Local $oVerb
    
    $oShell = ObjCreate("Shell.Application") 
    $oControlPanel = $oShell.Namespace(3)
    For $oFolderItem In $oControlPanel.Items 
    ; ConsoleWrite($oFolderItem.Name & @LF)
    ; Look up network connection folder name in control panel
        If $oFolderItem.Name = "Network Connections" Then 
            $oNetConnections = $oFolderItem.GetFolder
            ExitLoop
        EndIf
    Next     
    If Not IsObj($oNetConnections) Then Return 0
    For $oConnectionItem In $oNetConnections.Items 
    ; ConsoleWrite($oConnectionItem.Name & @LF)
        If $oConnectionItem.Name  = $sConnectionName Then 
            $oLanConnection = $oConnectionItem
            ExitLoop
        EndIf
    Next
    If Not IsObj($oLanConnection) Then Return 0
    For $oVerbItem In $oLanConnection.Verbs 
    ; ConsoleWrite($oVerbItem.Name & @LF)
        If $oVerbItem.Name = $sVerb Then 
            $oVerb = $oVerbItem
            ExitLoop
        EndIf
    Next
    If Not IsObj($oVerb) Then Return 0
    $oVerb.DoIt()
; Needs delay to allow action to complete
    Sleep(1000)
    
    Return 1
EndFunc
Edited by SumTingWong

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  

×