GodlessSinner Posted April 8, 2013 Share Posted April 8, 2013 Including disconnected adapters. Please help. _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
FireFox Posted April 8, 2013 Share Posted April 8, 2013 You can do this with the Winpcap library. There may be WinAPI solutions somewhere. Br, FireFox. Link to comment Share on other sites More sharing options...
GodlessSinner Posted April 8, 2013 Author Share Posted April 8, 2013 I can't found nothing about network in WinApi Management in Help.chm. What is Winpcap and how to use it in AutoIt or C#? _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
JohnOne Posted April 8, 2013 Share Posted April 8, 2013 Seen this via WMI but cannot remember where. If I recall it was something like "Select * from Win32_NetworkAdapter" AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted April 8, 2013 Share Posted April 8, 2013 (edited) I imagine you could also parse output from "ipconfig /all" command line. Edited April 8, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
UEZ Posted April 8, 2013 Share Posted April 8, 2013 (edited) Try this: #include <Array.au3> $sHost = @ComputerName $aNetworkAdapters = WMI_ListAllNetworkAdapters($sHost) _ArrayDisplay($aNetworkAdapters) Func WMI_ListAllNetworkAdapters($sHost) ;coded by UEZ 2013 Local $objWMIService = ObjGet("winmgmts:\\" & $sHost & "\root\cimv2") If @error Then Return SetError(1, 0, 0) Local $aStatus[13] = ["Disconnected", "Connecting", "Connected", "Disconnecting", "Hardware not present", "Hardware disabled", "Hardware malfunction", _ "Media Disconnected", "Authenticating", "Authentication Succeeded", "Authentication Failed", "Invalid Address", "Credentials Required"] $colItems = $objWMIService.ExecQuery("SELECT Name, NetConnectionID, NetConnectionStatus FROM Win32_NetworkAdapter", "WQL", 0x30) Local $aNetworkAdapters[1000][3], $i = 0, $iPointer If IsObj($colItems) Then For $objItem in $colItems With $objItem $aNetworkAdapters[$i][0] = .NetConnectionID $aNetworkAdapters[$i][1] = .Name $aNetworkAdapters[$i][2] = $aStatus[.NetConnectionStatus * 1] EndWith $i += 1 Next ReDim $aNetworkAdapters[$i][3] Return $aNetworkAdapters Else Return SetError(2, 0, 0) EndIf EndFunc Br, UEZ Edited April 9, 2013 by UEZ benwinnipeg and robertocm 2 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
GodlessSinner Posted April 9, 2013 Author Share Posted April 9, 2013 Try this: #include <Array.au3> $sHost = @ComputerName $aNetworkAdapters = WMI_ListAllNetworkAdapters($sHost) _ArrayDisplay($aNetworkAdapters) Func WMI_ListAllNetworkAdapters($sHost) ;coded by UEZ 2013 Local $objWMIService = ObjGet("winmgmts:\\" & $sHost & "\root\cimv2") If @error Then Return SetError(1, 0, 0) $colItems = $objWMIService.ExecQuery("SELECT Name, NetConnectionID FROM Win32_NetworkAdapter WHERE NetConnectionStatus IS NOT NULL", "WQL", 0x30) Local $aNetworkAdapters[1000][2], $i = 0 If IsObj($colItems) Then For $objItem in $colItems With $objItem $aNetworkAdapters[$i][0] = .NetConnectionID $aNetworkAdapters[$i][1] = .Name EndWith $i += 1 Next ReDim $aNetworkAdapters[$i][2] Return $aNetworkAdapters Else Return SetError(2, 0, 0) EndIf EndFunc Br, UEZ Thanks, but it returns only connected adapters, but I need ALL, I tried also without "WHERE NetConnectionStatus IS NOT NULL", and it doesn't returns disconnected adapters. _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
UEZ Posted April 9, 2013 Share Posted April 9, 2013 (edited) I've update the code from post#6. Please try it again. It can be that the NetConnectionID is empty. Check out for the name. Br, UEZ Edited April 9, 2013 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
GodlessSinner Posted April 12, 2013 Author Share Posted April 12, 2013 (edited) I've update the code from post#6. Please try it again. It can be that the NetConnectionID is empty. Check out for the name.Thanks, but it doesn't returns my disconected ppp(modem) adapters. Code return's only names of local connections.. Edited April 12, 2013 by GodlessSinner _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
JohnOne Posted April 12, 2013 Share Posted April 12, 2013 $objWMIService = ObjGet("winmgmts:\\.\root\cimv2") If Not IsObj($objWMIService) Then MsgBox(0,"Error","$objWMIService Not Object") Exit EndIf $sQuery = "Select * from Win32_NetworkAdapter" $colItems = $objWMIService.ExecQuery ($sQuery) If Not IsObj($colItems) Then MsgBox(0,"Error","$objWMIService Not Object") Exit EndIf ;MsgBox(0,0,VarGetType($colItems)) $sResult = "" $count = 0 For $objItem In $colItems $count += 1 ;$sResult &= "Index: " & $objItem.WINSScopeID & @CRLF ;$sResult &= "Caption: " & $objItem.Caption & @CRLF ;ConsoleWrite("> " & $sResult) $sResult &= "Name: " & $objItem.Name & @CRLF $sResult &= "Description: " & $objItem.Description & @CRLF ;ConsoleWrite("> " & $sResult) $sResult &= "MACAddress: " & $objItem.MACAddress & @CRLF ;ConsoleWrite("> " & $sResult) $sResult &= "NetConnectionStatus: " & $objItem.NetConnectionStatus & @CRLF ;ConsoleWrite("> " & $sResult) $sResult &= "GUID: " & $objItem.GUID & @CRLF ;For $strIPAddress In $objItem.IPAddress ; $sResult &= "IPAddress: " & $strIPAddress & @CRLF ;Next $sResult &= @CRLF Next ConsoleWrite("There are " & $count & " devices available" & @LF & @LF) ConsoleWrite($sResult & @LF) Digisoul 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
GodlessSinner Posted April 13, 2013 Author Share Posted April 13, 2013 (edited) Your code doesn't returns even connected internet(modem) adapters. It's seems impossible in C# and AutoIt and it can't be done via registry. Edited April 13, 2013 by GodlessSinner _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
JohnOne Posted April 13, 2013 Share Posted April 13, 2013 (edited) Well it returns every adapter I have on this computer. 30 in all. Are you talking about dial up/phone line modems? Edited April 13, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
GodlessSinner Posted April 13, 2013 Author Share Posted April 13, 2013 (edited) Are you talking about dial up/phone line modems?Yes, dial up/3G modem Edited April 13, 2013 by GodlessSinner _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
JohnOne Posted April 13, 2013 Share Posted April 13, 2013 Well I don't know about dial up cause I don't have one but it does detect my 3g modem. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
GodlessSinner Posted April 14, 2013 Author Share Posted April 14, 2013 I have searched for it in most programing languages and it seems like impossible... Sad. _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
FireFox Posted April 14, 2013 Share Posted April 14, 2013 The snippets provided work well, make sure you run them with admin rights (or add #RequireAdmin) Br, FireFox. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now