P.S.
not exactly on topic and a bit late, anyway....
this should list network connections, (don't know if also RAS connections)
also let you enable or disable selected connections.
It uses the "netsh" command that is localized, check lines78 and 87 for correct lacalized msg
(found here: http://www.eng2ita.net/forum/index.php/topic,7610.0.html)
#include <GUIConstantsEx.au3>
#include <Constants.au3>
;~ #include <Array.au3>
#include <GuiListView.au3>
#include <Process.au3>
Opt("GUIOnEventMode", 1)
Local $line_1, $read00, $listview, $button, $Counter, $item, $textitem, $textitem2
$netshow = "netsh interface show interface"
$flushdns = "ipconfig /flushdns"
$NetGui = GUICreate("Net Switch", 520, 280, -1, -1)
$listview = GUICtrlCreateListView("Interface name|Admin state|State|Type", 10, 10, 500, 218)
GUICtrlCreateGroup("", 10, 230, 290, 42)
$button1 = GUICtrlCreateButton("Enable", 20, 244, 70, 20)
GUICtrlSetTip($button1, "Enables the selected network interface")
GUICtrlSetOnEvent($button1, "_button1")
$button2 = GUICtrlCreateButton("Disable", 120, 244, 70, 20)
GUICtrlSetTip($button2, "Disables the selected network interface")
GUICtrlSetOnEvent($button2, "_button2")
$button3 = GUICtrlCreateButton("Update", 220, 244, 70, 20)
GUICtrlSetTip($button3, "Update the reading of the interfaces by Netsh")
GUICtrlSetOnEvent($button3, "_button3")
GUICtrlCreateGroup("", 320, 230, 190, 42)
$button4 = GUICtrlCreateButton("Pubblic Ip", 330, 244, 70, 20)
GUICtrlSetTip($button4, "Gets the public IP address and copy to clipboard")
GUICtrlSetOnEvent($button4, "_button4")
$button5 = GUICtrlCreateButton("Flushdns", 430, 244, 70, 20)
GUICtrlSetTip($button5, "Clear your DNS cache")
GUICtrlSetOnEvent($button5, "_button5")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
netshow()
Func netshow()
$readnetshow = Run($netshow, @SystemDir, @SW_HIDE, $STDOUT_CHILD)
Local $line
While 1
$line &= StdoutRead($readnetshow)
If @error Then ExitLoop
WEnd
$line_1 = StringSplit($line, @CRLF);~ _ArrayDisplay($line_1)
For $i = 7 To UBound($line_1) - 5 Step 2
$read00 = StringSplit($line_1[$i], @CRLF);~ _ArrayDisplay($read00)
For $i1 = 1 To UBound($read00) - 1 Step 1
$readstate = StringRegExp($read00[1], "\S+", 3);~ MsgBox(1, "", $readstate[0]) ; Abilitato o Disabilitato ;~ MsgBox(1, "", $readstate[1]) ; Connessione o Disconnesso ;~ MsgBox(1, "", $readstate[2]) ; Dedicato
$readconn = StringTrimLeft($read00[$i1], 47) ;~ MsgBox(1, "", $readconn) ; Nome della Connessione
$item = GUICtrlCreateListViewItem($readconn & "|" & $readstate[0] & "|" & $readstate[1] & "|" & $readstate[2], $listview)
Next
Next
_GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_SetColumnWidth($listview, 0, $LVSCW_AUTOSIZE); $LVSCW_AUTOSIZE $LVSCW_AUTOSIZE_USEHEADER
_GUICtrlListView_SetItemSelected($listview, 0)
EndFunc ;==>netshow
GUISetBkColor(0xF0F4F9)
GUISetState(@SW_SHOW)
While 1
Sleep(10)
WEnd
Func _Exit()
Exit
EndFunc ;==>_Exit
Func _refresh()
_GUICtrlListView_DeleteAllItems($listview)
netshow()
EndFunc ;==>_refresh
Func _button1()
$Indices = _GUICtrlListView_GetSelectedIndices($listview)
$Indices2 = StringSplit($Indices, "|")
For $x = 1 To $Indices2[0] Step 1
$textitem = _GUICtrlListView_GetItemText($listview, Int($Indices2[$x])) ;~ MsgBox(4160, "Info", "Item selezionato: " & $textitem)
$textitem2 = _GUICtrlListView_GetItemText($listview, Int($Indices2[$x]), 1);~ MsgBox(4160, "Info", "SubItem selezionato >>" & $textitem2 &"<<")
If Not ($textitem2 = "Enabled") Then _enableadapter()
Next
EndFunc ;==>_button1
Func _button2()
$Indices = _GUICtrlListView_GetSelectedIndices($listview)
$Indices2 = StringSplit($Indices, "|")
For $x = 1 To $Indices2[0] Step 1
$textitem = _GUICtrlListView_GetItemText($listview, Int($Indices2[$x])) ;~ MsgBox(4160, "Info", "Item selezionato: " & $textitem)
$textitem2 = _GUICtrlListView_GetItemText($listview, Int($Indices2[$x]), 1) ;~ MsgBox(4160, "Info", "SubItem selezionato >>" & $textitem2 &"<<")
If Not ($textitem2 = "Disabled") Then _disableadapter()
Next
EndFunc ;==>_button2
Func _button3()
_refresh()
EndFunc ;==>_button3
; #FUNCTION# =========================================================================================================
; Name...........: _GetIP
; Description ...: Retrieves the Public IP Address of a Network/Computer.
; Syntax.........: _GetIP()
; Parameters ....: None
; Requirement(s).: v3.3.2.0 or higher
; Return values .: Success - Returns Public IP Address.
; Failure - Returns -1 & sets @error = 1
; Author ........: guinness
; Example........; Yes
;=====================================================================================================================
Func _GetIP()
Local $aReturn, $bRead, $sRead
$bRead = InetRead("http://checkip.dyndns.org/")
$sRead = BinaryToString($bRead)
$aReturn = StringRegExp($sRead, '(?s)(?i)<body>Current IP Address: (.*?)</body>', 3)
If @error = 0 Then
Return $aReturn[0]
EndIf
$bRead = InetRead("http://automation.whatismyip.com/n09230945.asp") ; http://forum.whatismyip.com/f14/our-automation-rules-t241/
$sRead = BinaryToString($bRead)
If @error Then
Return SetError(1, 0, -1)
EndIf
Return $sRead
EndFunc ;==>_GetIP
Func _button4()
$PublicIP = _GetIP()
If @error <> 0 Then
MsgBox(16, "Error", "Unable to get the public address")
Else
MsgBox(64, "Ip Address", $PublicIP)
ClipPut($PublicIP)
EndIf
EndFunc ;==>_button4
Func _button5()
$flushdnscmd = Run($flushdns, @SystemDir, @SW_HIDE, $STDOUT_CHILD)
Local $lineflush
While 1
$lineflush &= StdoutRead($flushdnscmd)
If @error Then ExitLoop
WEnd
MsgBox(64, "Flushdns", $lineflush )
;~ _RunDOS("ipconfig /flushdns")
EndFunc ;==>_button5
Func _enableadapter()
_RunDOS('netsh interface set interface "' & $textitem & '" enabled')
_refresh()
EndFunc ;==>_enableadapter
Func _disableadapter()
_RunDOS('netsh interface set interface "' & $textitem & '" disabled')
_refresh()
EndFunc ;==>_disableadapter