Sign in to follow this  
Followers 0
erifash

Get the PCs on the local network

2 posts in this topic

How can you return the names of the computers on the local network using WMI? Here is the code I have so far...

Func _GetPCs( $sDomain = @COMPUTERNAME )
    Local $oDomain = ObjGet("WinNT://" & $sDomain), $c = 2, $pc[999][2]
    If @error Then
        SetError(1)
        Return ""
    EndIf
    $pc[1][0] = @COMPUTERNAME
    $pc[1][1] = @IPADDRESS1
    $pc[0][0] = 1
    For $o In $oDomain
        If $o.class = "Computer" Then
            $pc[$c][0] = $o.Name
            $pc[$c][1] = TCPNameToIP($pc[$c][0])
            $pc[0][0] = $c
            $c += 1
        EndIf
    Next
    ReDim $pc[$c][2]
    Return $pc
EndFunc
I am having real problems with this... :P

Share this post


Link to post
Share on other sites



$pcs = _GetPCs("MyHome")
For $x = 1 To $pcs[0][0]
 ConsoleWrite($pcs[$x][0] & ", " & $pcs[$x][1] & @LF)
Next

Func _GetPCs( $sDomain = @COMPUTERNAME )
  TCPStartup()
   Local $oDomain = ObjGet("WinNT://" & $sDomain), $pc[1][2]
    If @error Then
        SetError(1)
        Return ""
    EndIf
    $pc[0][0] = 0
    For $o In $oDomain
        If $o.class = "Computer" Then
    ReDim $pc[UBound($pc) + 1][2]
            $pc[UBound($pc) - 1][0] = $o.Name
            $pc[UBound($pc) - 1][1] = TCPNameToIP($pc[UBound($pc) - 1][0])
            $pc[0][0] = UBound($pc) - 1
        EndIf
    Next
  TCPShutdown()
    Return $pc
EndFunc


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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