Sign in to follow this  
Followers 0
billthecreator

Who's in my network

8 posts in this topic

Try this:

#Include <Array.au3>
#include <iNet.au3>
TCPStartup()

Global $aComputers[255][2]
Global $count = 0
Global $IP = @IPAddress1

$minIP = 100;192.168.0.100 is the lowest IP i have
$maxIP = 110;192.168.0.110 is the highest IP i will have, so no need to go higher/lower

If $IP = "127.0.0.1" Then
    MsgBox(0, "Error", "It appears no connection is availible.  Now exiting...")
    Exit
EndIf

$aIP = StringSplit($IP, ".")

If $aIP[0] <> 4 Then
    MsgBox(0, "", "Invailid IP (Possibly using IPv6),  Now exiting...")
    Exit
EndIf

$pre = $aIP[1] & "." & $aIP[2] & "." & $aIP[3] & "."

For $i = $minIP to $maxIP
    $pingIP = $pre & $i
    TrayTip ("", "Now Pinging... " & $pingIP, 10)
    $ping = Ping ($pingIP, 75)
    If $ping Then
        $name = _TCPIpToName ($pingIP)
        If @error Then $name = -1 & "(error = " & @error & ")"
        $count += 1
        $aComputers[$count][0] = $pingIP
        $aComputers[$count][1] = $name
    EndIf
Next

MsgBox (0, "", $count & " computers found!")

ReDim $aComputers[$count + 1][2]
$aComputers[0][0] = $count
_ArrayDisplay ($aComputers)
TCPShutdown ( )

Cheers,

Brett

Share this post


Link to post
Share on other sites

If there is already associated name with each machine it's all in the registry under the key (for Windows XP):

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComputerDescriptions

Just use RegEnumKey to enumerate them all.

Share this post


Link to post
Share on other sites

So use the search as I did. I've search for a known name of one of our machines in the network, probably there is a parallel key in Vista. If no, there is always the good WMI object to retrieve some Windows properties of your machine account.

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  
Followers 0