Jump to content

Get all computers connected to the router


Recommended Posts

Hi,

I have seen an application that does this:

It lists all the computers/devices connected to your internet device and it gives informations such as:

IPAddress

MacAddress

Names if it is a computer

and name of the devices(for example 1=computer 2=Mobile device iPhone 3=other devices)

I know how to get DNSdomain, hostname, ipaddress, subnet and mac address of localhost. This is not what i am searching.
I am trying to get the informations above of all the devices connected to my internet device. Ethernet and wireless.

So anyone has any ideas?
 

Link to comment
Share on other sites

Link to comment
Share on other sites

  • Moderators

It depends on the router, too. I know that some routers allow you to pull this information pretty easily. The old WRT series stored the list at <router address>/DeviceList.asp, for example. I'm not sure there is an (easy, anyway) one size fits all solution.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

the easiest way is to scan the IP range. it can be scripted with AutoIt, if you insist; but there are ready-made tools for this. here are two of them i found very useful:

http://www.nirsoft.net/utils/netresview.html

http://www.softperfect.com/products/networkscanner/

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

the easiest way is to scan the IP range. it can be scripted with AutoIt, if you insist; but there are ready-made tools for this. here are two of them i found very useful:

http://www.nirsoft.net/utils/netresview.html

http://www.softperfect.com/products/networkscanner/

I'd also recommend nmap and zenmap (gui for nmap).

Link to comment
Share on other sites

Hi AutID

if you want to discover all devices in your local LAN, then you could use my multiping udf (https://www.autoitscript.com/forum/topic/156395-versatile-multi-ping)

here a simple example of use that will scann all IP devices of your local subnet and will display result by green boxes in a listview.
then will continuosly ping those devices showing a red box when one of them will go offline.

(You need first to download the MultiPing.au3 and save it in the same directory of this example.)

; this is to ping continuously a list of IP addresses, get and display ping result "live"
; it simulates the dos "ping -t" command but performed simultaneously on many IP
; presenting the results in a ListView highlighting not responding devices with a red box

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ListviewConstants.au3>

#include 'MultiPing.au3' ; <-- take this from the following link:
; http://www.autoitscript.com/forum/topic/156395-versatile-multi-ping

Local $IP_range = "" ; range to be pinged (leave it empty to ping all local lan)
Local $IP_mask = ""

Opt("GUIOnEventMode", 1)
HotKeySet("{esc}", "_button1")

Local $Win_X = 600, $Win_Y = 600 ; dimension of window
$PingGui = GUICreate("IP addresses monitor", $Win_X, $Win_Y, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui)
$listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40)
GUICtrlSetFont(-1, 6)
GUICtrlSetStyle($listview, $LVS_ICON + $LVS_NOLABELWRAP)

; Generate colored square images
$hImage = _GUIImageList_Create(16, 16)
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 16, 16)) ; yellow
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 16, 16)) ; red
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 16, 16)) ; green

_GUICtrlListView_SetImageList($listview, $hImage, 0)

$button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20)
GUICtrlSetTip(-1, "End of program")
GUICtrlSetOnEvent(-1, "_button1")
GUISetState(@SW_SHOW)

$MyArray = _nPing($IP_range, $IP_mask, 1, 1) ;  first call is to generate the array
;                                               this will search for all active IP devices
;                                               and make a "snapshot" in the $MyArrat

_ArrayDelete($MyArray, 0) ; remove first item
; _ArrayDisplay($MyArray)
_GUICtrlListView_BeginUpdate($listview)
_GUICtrlListView_AddArray($listview, $MyArray) ; and fill ListView
_GUICtrlListView_EndUpdate($listview)

While 1 ; continuously ping addresses of the snapshot previously generated
    Sleep(10)
    _nPing($MyArray, 0, 0, 0, "_refresh") ; PING required addresses and call the _refresh() function
    ;                                        for each terminated ping (reasults of ping are passed to function)
WEnd

Func _button1() ; Button 1 clicked
    Exit
EndFunc   ;==>_button1

Func _refresh($Params) ; this receive ping results and displays them in the ListView
    _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow
    Sleep(50) ; a little wait
    If $Params[4] = -1 Then ; Device not responding to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED
        _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item
    Else ; Device responds to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN
    EndIf
EndFunc   ;==>_refresh
Edited by Gianni
fixed broken links

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 10 years later...

thats a wonderfull ipscanner, but how i can modifiy it to open explorer into \\IP\c$ when i click a computer, i tried to do it, but i get only redeclae problems. 

 

 

Tnx for helping

 

greetings

Casi

Link to comment
Share on other sites

On 6/15/2024 at 2:03 PM, casi4711 said:

thats a wonderfull ipscanner, but how i can modifiy it to open explorer into \\IP\c$ when i click a computer, i tried to do it, but i get only redeclae problems. 

Hi @casi4711

here's a "quick and dirty" modification to the above script that should achieve what you're asking for when you double-click on a "computer".
I hope it is useful to you
bye

; this is to ping continuously a list of IP addresses, get and display ping result "live"
; it simulates the dos "ping -t" command but performed simultaneously on many IP
; presenting the results in a ListView highlighting not responding devices with a red box

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ListviewConstants.au3>
#include <WindowsConstants.au3>

#include 'MultiPing.au3' ; <-- take this from the following link :
; http://www.autoitscript.com/forum/topic/156395-versatile-multi-ping

Global $listview, $hLV_Handle, $iRow, $bClick = False

_IP_Scanner()

Func _IP_Scanner($IP_range = '', $IP_mask = '')

    ; Local $IP_range = "" ; range to be pinged (leave it empty to ping all local lan)
    ; Local $IP_mask = ""
    Local $sClickedItemText
    Opt("GUIOnEventMode", 1)
    HotKeySet("{esc}", "_button1")

    Local $Win_X = 600, $Win_Y = 600 ; dimension of window
    Local $PingGui = GUICreate("IP addresses monitor", $Win_X, $Win_Y, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui)
    $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40)
    $hLV_Handle = GUICtrlGetHandle($listview)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY_Handler")

    GUICtrlSetFont(-1, 6)
    GUICtrlSetStyle($listview, $LVS_ICON + $LVS_NOLABELWRAP)

    ; Generate colored square images
    $hImage = _GUIImageList_Create(16, 16)
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 16, 16)) ; yellow
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 16, 16)) ; red
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 16, 16)) ; green

    _GUICtrlListView_SetImageList($listview, $hImage, 0)

    $button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20)
    GUICtrlSetTip(-1, "End of program")
    GUICtrlSetOnEvent(-1, "_button1")
    GUISetState(@SW_SHOW)

    $MyArray = _nPing($IP_range, $IP_mask, 1, 1) ;  first call is to generate the array
    ;                                               this will search for all active IP devices
    ;                                               and make a "snapshot" in the $MyArrat

    _ArrayDelete($MyArray, 0) ; remove first item
    ; _ArrayDisplay($MyArray)
    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_AddArray($listview, $MyArray) ; and fill ListView
    _GUICtrlListView_EndUpdate($listview)

    While 1 ; continuously ping addresses of the snapshot previously generated
        Sleep(10)
        _nPing($MyArray, 0, 0, 0, "_refresh") ; PING required addresses and call the _refresh() function
        ;                                        for each terminated ping (reasults of ping are passed to function)
        ;
        ; ------------------------------------------------------
        ; ---- manage your click (doubleclick) action here below
        ; ------------------------------------------------------
        If $bClick Then
            $bClick = False ; clear the flag immediately

            $sClickedItemText = _GUICtrlListView_GetItemText($hLV_Handle, $iRow)  ; Clicked device (IP address)

            ; ConsoleWrite('Debug: --> ' & $sClickedItemText & @CRLF)
            If $sClickedItemText Then ShellExecute('\\' & $sClickedItemText & '\c$')
        EndIf
        ; ------------------------------------------------------
        ;
    WEnd
EndFunc   ;==>_IP_Scanner
Func _button1() ; Button 1 clicked
    Exit
EndFunc   ;==>_button1

Func _refresh($Params) ; this receive ping results and displays them in the ListView
    _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow
    Sleep(50) ; a little wait
    If $Params[4] = -1 Then ; Device not responding to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED
        _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item
    Else ; Device responds to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN
    EndIf
EndFunc   ;==>_refresh

; https://www.autoitscript.com/forum/topic/155607-how-to-detect-which-listview-was-clicked/
Func _WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam)
    If @error Then Return

    Switch DllStructGetData($tStruct, 1)
        Case $hLV_Handle
            If BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) = $NM_DBLCLK Then
                $iRow = DllStructGetData($tStruct, 4)
                ; $iCol = DllStructGetData($tStruct, 5)
                ; Set flags
                $bClick = True
            EndIf
        Case Else
            Return
    EndSwitch
EndFunc   ;==>_WM_NOTIFY_Handler

 

Edited by Gianni

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Thx fpr u replay, wonderful work, but how i can adjust the IP range in the original script i could adjzust it like: Local $IP_range = "192.168.178" Thats no working any longer.

 

greetings

 

 

casi

 

 

Link to comment
Share on other sites

hi @casi4711

the address "192.168.178" is incomplete and represents neither a range nor a single address. What address range do you intend to ping?

For example, if you want to ping all addresses from 192.168.178.0 to 192.168.178.255 then you can use this range value "192.168.178.*"
the asterisk indicates all possible values (0 to 255)
for other possible examples of valid ranges take a look here:
https://www.autoitscript.com/forum/topic/156395-versatile-multi-ping

Edited by Gianni

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • 1 month later...

Hello Gianni,

ive modified this script a little bit to show the PC Names on the grid. The Ips i stored in the array for later use, my idea to show the additionoal informaion like ip with a tooltip on mouseover. But my question: In my network are serveral devices, that no handle with ICMP, and so are not listed. Do u have a clue, how to implement a ARP Ping Scan? Now my script lloks like:

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ListviewConstants.au3>
#include <WindowsConstants.au3>

#include 'MultiPing.au3' ; <-- take this from the following link : ; http://www.autoitscript.com/forum/topic/156395-versatile-multi-ping
Global $listview, $hLV_Handle, $iRow, $bClick = False

_IP_Scanner()

Func _IP_Scanner($IP_range = '192.168.178.1-255', $IP_mask = '')
    Local $sClickedItemText
    Opt("GUIOnEventMode", 1)
    HotKeySet("{esc}", "_button1")
    Local $Win_X = 600, $Win_Y = 300 ; dimension of window
    Local $PingGui = GUICreate("IP addresses monitor", $Win_X, $Win_Y, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui)

    ; Create Listview
    $listview = GUICtrlCreateListView("Computer Name|IP Address", 10, 10, $Win_X - 20, $Win_Y - 40, -1, $LVS_REPORT)
    $hLV_Handle = GUICtrlGetHandle($listview)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY_Handler")
    GUICtrlSetFont(-1, 9) ; Größere Schriftgröße
    GUICtrlSetStyle($listview, $LVS_ICON + $LVS_NOLABELWRAP)
    $button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20)
    GUICtrlSetTip(-1, "End of program")
    GUICtrlSetOnEvent(-1, "_button1")
    GUISetState(@SW_SHOW)

    ; Generate colored square images
    $hImage = _GUIImageList_Create(16, 16)
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 16, 16)) ; yellow
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 16, 16)) ; red
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 16, 16)) ; green
    _GUICtrlListView_SetImageList($listview, $hImage, 0)

    $MyArray = _nPing($IP_range, $IP_mask, 1, 1) ; first call is to generate the array

    ; Create new array to store both computer name and IP address
    Local $DisplayArray[UBound($MyArray)][2]

    ; Replace IP addresses with computer names using DNS lookup and store IP
    For $i = 0 To UBound($MyArray) - 1
        $DisplayArray[$i][0] = _GetComputerName($MyArray[$i][0])
        $DisplayArray[$i][1] = $MyArray[$i][0]

        ; Debug-Ausgabe: Überprüfen des $DisplayArray-Inhalts
        ;ConsoleWrite("DisplayArray[" & $i & "][0]: " & $DisplayArray[$i][0] & " | DisplayArray[" & $i & "][1]: " & $DisplayArray[$i][1] & @CRLF)
    Next

    ; Remove the first row containing "Unknown"
    For $i = 0 To UBound($DisplayArray) - 1
        If $DisplayArray[$i][0] = "Unknown" Then
            _ArrayDelete($DisplayArray, $i)
            ExitLoop
        EndIf
    Next
;_ArrayDisplay($DisplayArray, "DisplayArray") ; Display the array

    _GUICtrlListView_BeginUpdate($listview)

    For $i = 0 To UBound($DisplayArray) - 1
        _GUICtrlListView_AddItem($listview, $DisplayArray[$i][0], $i)
        _GUICtrlListView_AddSubItem($listview, $i, $DisplayArray[$i][1], 1)
    Next
    _GUICtrlListView_EndUpdate($listview)

    While 1 ; continuously ping addresses of the snapshot previously generated
        Sleep(10)
        _nPing($MyArray, 0, 0, 0, "_refresh") ; PING required addresses and call the _refresh() function
        ; for each terminated ping (results of ping are passed to function)

        ; ------------------------------------------------------
        ; ---- manage your click (doubleclick) action here below
        ; ------------------------------------------------------
        If $bClick Then
            $bClick = False ; clear the flag immediately
            $sClickedItemText = _GUICtrlListView_GetItemText($hLV_Handle, $iRow, 1) ; Clicked device (IP address)
            If $sClickedItemText Then ShellExecute('\\' & $sClickedItemText & '\c$')
        EndIf
        ; ------------------------------------------------------
    WEnd
EndFunc   ;==>_IP_Scanner

Func _GetComputerName($ipAddress)
    Local $sComputerName = "Unknown"
    Local $sCmd = "nslookup " & $ipAddress
    Local $aResult = Run(@ComSpec & " /c " & $sCmd, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $sOutput = ""

    While 1
        $sOutput &= StdoutRead($aResult)
        If @error Then ExitLoop
    WEnd

    If StringInStr($sOutput, "Name:") Then
        Local $sPattern = "Name:\s+([^\r]+)"
        Local $aMatches = StringRegExp($sOutput, $sPattern, 1)
        If IsArray($aMatches) Then
            $sComputerName = $aMatches[0]
            $sComputerName = StringStripWS($sComputerName, 3)
            $sComputerName = StringRegExpReplace($sComputerName, "\..*", "") ; Abschneiden ab dem ersten Punkt
        EndIf
    EndIf
    Return $sComputerName
EndFunc

Func _refresh($Params) ; this receives ping results and displays them in the ListView
    Local $sClickedItemText = _GUICtrlListView_GetItemText($hLV_Handle, $Params[5], 0) ; get computer name from ListView item
    _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow
    Sleep(50) ; a little wait
    If $Params[4] = -1 Then ; Device not responding to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED
        _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item
    Else ; Device responds to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN
    EndIf
EndFunc   ;==>_refresh

Func _button1() ; Button 1 clicked
    Exit
EndFunc   ;==>_button1

Func _WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam)
    If @error Then Return

    Switch DllStructGetData($tStruct, 1)
        Case $hLV_Handle
            If BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) = $NM_DBLCLK Then
                $iRow = DllStructGetData($tStruct, 4)
                $bClick = True
            EndIf
        Case Else
            Return
    EndSwitch
EndFunc   ;==>_WM_NOTIFY_Handler

many greetings

 

casi

 

 

 

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...