Jump to content

Recommended Posts

Posted

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
Posted

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

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...