Alle Netzwerk Pcs anzeigen

  • frag mich nicht woher ich das hab. ich weiß es nicht.
    aber war mal iwo hier im forum.

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $SV_TYPE_WORKSTATION = 0x1
    Global Const $SV_TYPE_SERVER = 0x2
    Global Const $SV_TYPE_SQLSERVER = 0x4
    Global Const $SV_TYPE_DOMAIN_CTRL = 0x8
    Global Const $SV_TYPE_DOMAIN_BAKCTRL = 0x10
    Global Const $SV_TYPE_TIME_SOURCE = 0x20
    Global Const $SV_TYPE_AFP = 0x40
    Global Const $SV_TYPE_NOVELL = 0x80
    Global Const $SV_TYPE_DOMAIN_MEMBER = 0x100
    Global Const $SV_TYPE_PRINTQ_SERVER = 0x200
    Global Const $SV_TYPE_DIALIN_SERVER = 0x400
    Global Const $SV_TYPE_XENIX_SERVER = 0x800
    Global Const $SV_TYPE_NT = 0x1000
    Global Const $SV_TYPE_WFW = 0x2000
    Global Const $SV_TYPE_SERVER_MFPN = 0x4000
    Global Const $SV_TYPE_SERVER_NT = 0x8000
    Global Const $SV_TYPE_POTENTIAL_BROWSER = 0x10000
    Global Const $SV_TYPE_BACKUP_BROWSER = 0x20000
    Global Const $SV_TYPE_MASTER_BROWSER = 0x40000
    Global Const $SV_TYPE_DOMAIN_MASTER = 0x80000
    Global Const $SV_TYPE_WINDOWS = 0x400000
    Global Const $SV_TYPE_CLUSTER_NT = 0x1000000
    Global Const $SV_TYPE_TERMINALSERVER = 0x2000000
    Global Const $SV_TYPE_CLUSTER_VS_NT = 0x4000000
    Global Const $SV_TYPE_LOCAL_LIST_ONLY = 0x40000000
    Global Const $SV_TYPE_DOMAIN_ENUM = 0x80000000
    Global Const $SV_TYPE_ALL = 0xFFFFFFFF

    [/autoit] [autoit][/autoit] [autoit]

    $aCompList = _NetServerEnum($SV_TYPE_WORKSTATION)

    [/autoit] [autoit][/autoit] [autoit]

    _ArrayDisplay($aCompList)

    [/autoit] [autoit][/autoit] [autoit]

    Func _NetServerEnum ($iSrvType = -1, $sDomain = '')
    Local $uBufPtr = DllStructCreate("ptr;int;int"), $res[1]=[0], $i
    Local $uRecord = DllStructCreate("dword;ptr"), $iRecLen = DllStructGetSize($uRecord)
    Local $uString = DllStructCreate("char[16]")
    Local $uDomain = DllStructCreate("byte[32]"), $pDomain = 0
    If Not ($sDomain='' Or $sDomain='*') Then
    DllStructSetData($uDomain, 1, StringToBinary($sDomain,2))
    $pDomain = DllStructGetPtr($uDomain)
    EndIf
    Local $ret = DllCall ("netapi32.dll", "int", "NetServerEnum", _
    "ptr", 0, "int", 100, _
    "ptr", DllStructGetPtr($uBufPtr,1), "int", -1, _
    "ptr", DllStructGetPtr($uBufPtr,2), _
    "ptr", DllStructGetPtr($uBufPtr,3), _
    "int", $iSrvType, "ptr", $pDomain, "int", 0 )
    If $ret[0] Then Return SetError(1, $ret[0], '')
    Local $res[DllStructGetData($uBufPtr,3)+1]=[DllStructGetData($uBufPtr,3)]
    For $i=1 To DllStructGetData($uBufPtr,3)
    Local $uRecord = DllStructCreate("dword;ptr", DllStructGetData($uBufPtr,1)+($i-1)*$iRecLen)
    Local $sNBName = DllStructCreate("byte[32]", DllStructGetData($uRecord,2))
    DllStructSetData($uString,1,BinaryToString(DllStructGetData($sNBName,1),2))
    $res[$i] = DllStructGetData($uString,1)
    Next
    $ret = DllCall ("netapi32.dll", "int", "NetApiBufferFree", "ptr", DllStructGetData($uBufPtr,1))
    Return $res
    EndFunc

    [/autoit]

    edit: ah ich glaub ich habs gefunden:
    https://autoit.de/index.php?page=Thread&postID=51440#post51440

  • Die funktion findet nur meinen pc obwohl der von meinem Vater auch da ist und auch bei netzwerk angezeigt wird, bzw ich mit net session im cmd finden lässt. Achja und wir haben verschiedene Arbeitsgruppen aber es muss auch so gehen.

    • Offizieller Beitrag

    Geht das?

    Spoiler anzeigen
    [autoit]

    #include<GuiListView.au3>
    #include<Array.au3>
    #include<GUIConstantsEx.au3>
    #include<ListViewConstants.au3>
    GUICreate("NetView in ListView", 520, 550, 100, 100, -1)
    GUISetBkColor(0x00E0FFFF) ; will change background color

    [/autoit] [autoit][/autoit] [autoit]

    $listview = GUICtrlCreateListView("Rechnername|Kommentar|IP", 10, 10, 400, 450, Default, $LVS_EX_GRIDLINES)
    _GUICtrlListView_SetColumnWidth($listview, 2, $LVSCW_AUTOSIZE_USEHEADER)

    [/autoit] [autoit][/autoit] [autoit]

    Global $s_Comments[1], $n_IP[1]
    Global $s_Servernames = Net_View()

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To UBound($s_Servernames) - 1
    GUICtrlCreateListViewItem($s_Servernames[$i] & '|' & $s_Comments[$i] & '|' & $n_IP[$i], $listview)
    Next
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit (0)
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Net_View()
    Local $s_Buf = ''
    Local $a_Buf = ''
    Local $i_Pid = Run(@ComSpec & ' /c net view', '', @SW_HIDE, 2 + 4)
    While Not @error
    $s_Buf &= StdoutRead($i_Pid)
    If @error Then ExitLoop
    WEnd
    Local $netView_Lines = StringSplit($s_Buf, @LF)
    ReDim $s_Comments[UBound($netView_Lines) ]
    For $i = 4 To UBound($netView_Lines) - 1
    $s_Comments[$i - 4] = StringMid($netView_Lines[$i], 24, 30)
    Next
    $a_Buf = StringRegExp($s_Buf, "\\\\([0-9a-zA-Z-]*)", 3)
    ReDim $n_IP[UBound($a_Buf) ]
    TCPStartup()
    For $i = 1 TO UBound($a_Buf) -1
    $n_IP[$i] = TCPNameToIP($a_Buf[$i])
    Next
    TCPShutdown ( )
    ProcessClose($i_Pid)
    Return $a_Buf
    EndFunc ;==>Net_View

    [/autoit]
  • Hallo Xenobiologist,

    du solltest nach Zeile 39 noch abfragen ob $a_Buf ein Array ist

    [autoit]

    $a_Buf = StringRegExp($s_Buf, "\\\\([0-9a-zA-Z-]*)", 3) ;Zeile 39
    if not IsArray($a_Buf) then Return ;Skript steigt sonst in der nächsten Zeikle aus wenn $a_Buf kein Array ist
    ReDim $n_IP[UBound($a_Buf) ]

    [/autoit]

    mfg (Auto)Bert

  • Ich hab auch mal früher aus langeweile so ein Script geschrieben nach dem Prinzip nach und nach alle IP's anzupingen.

    Spoiler anzeigen
    [autoit]

    #include <iNet.au3>
    #Include <GuiComboBox.au3>
    #include <ComboConstants.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    $n = ""
    TraySetIcon("Shell32.dll", -19)
    While FileExists(@ScriptDir & "/IP"&$n&".txt")
    $n = $n+1
    WEnd
    $ipstart = InputBox("IP Start", "Z.B. 192.168.4.0", "192.168.0.0")
    $ipstopp = InputBox("IP Ende", "Z.B. 192.168.5.91", "192.168.0.255")
    $ipstart = StringSplit($ipstart, ".")
    $ipstopp = StringSplit($ipstopp, ".")
    If $ipstart[0] <> 4 Then
    MsgBox(16, "Fehler", "Keine gültige Start-Ip-Adresse eingegeben")
    EndIf
    If $ipstopp[0] <> 4 Then
    MsgBox(16, "Fehler", "Keine gültige End-Ip-Adresse eingegeben")
    EndIf
    $timeout = InputBox("Timeout", "Zeit um auf Antwort zu warten", "50")
    $a = 0
    FileWrite(@ScriptDir & "/IP"&$n&".txt", "Starte Suche: " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
    FileWrite(@ScriptDir & "/IP"&$n&".txt", "Start-Ip = "& $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] &@CRLF)
    FileWrite(@ScriptDir & "/IP"&$n&".txt", "End-Ip = " & $ipstopp[1]&"."&$ipstopp[2]&"."&$ipstopp[3]&"."&$ipstopp[4] & @CRLF)
    Do
    ;~ ToolTip($ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4], 0, 0, $ipstopp[1]&"."&$ipstopp[2]&"."&$ipstopp[3]&"."&$ipstopp[4])
    $ping = Ping($ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4], $timeout)
    If $ping > 0 Then
    $rip = $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4]
    TCPStartup()
    $name = _TCPIpToName($rip)
    If @error = 0 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & @CRLF & "=============================" & @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Ping: " & $ping & @CRLF & "Hostname: " & $name & @CRLF & "=============================" & @CRLF)
    EndIf
    If @error = 1 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & @CRLF & "=============================" & @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Ping: " & $ping & @CRLF & "Hostname: " & "inet_addr DllCall fehlgeschlagen" & @CRLF & "=============================" & @CRLF)
    EndIf
    If @error = 2 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & @CRLF & "=============================" & @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Ping: " & $ping & @CRLF & "Hostname: " & "inet_addr fehlgeschlagen" & @CRLF & "=============================" & @CRLF)
    EndIf
    If @error = 3 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & @CRLF & "=============================" & @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Ping: " & $ping & @CRLF & "Hostname: " & "gethostbyaddr DllCall fehlgeschlagen" & @CRLF & "=============================" & @CRLF)
    EndIf
    If @error = 4 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & @CRLF & "=============================" & @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Ping: " & $ping & @CRLF & "Hostname: " & "gethostbyaddr fehlgeschlagen, WSAGetLastError = @Extended" & @CRLF & "=============================" & @CRLF)
    EndIf
    If @error = 5 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & @CRLF & "=============================" & @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Ping: " & $ping & @CRLF & "Hostname: " & "gethostbyaddr fehlgeschlagen, WSAGetLastError fehlgeschlagen" & @CRLF & "=============================" & @CRLF)
    EndIf
    If @error = 6 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & @CRLF & "=============================" & @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Ping: " & $ping & @CRLF & "Hostname: " & "strlen/sZStringRead fehlgeschlagen" & @CRLF & "=============================" & @CRLF)
    EndIf
    If @error = 7 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & @CRLF & "=============================" & @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Ping: " & $ping & @CRLF & "Hostname: " & "Fehler beim Lesen des Aliases Array" & @CRLF & "=============================" & @CRLF)
    EndIf
    TCPShutdown()
    $a += 1
    TrayTip("IP Lan", $a & " Router/Computer gefunden", 0, 1)
    EndIf
    If $ping = 0 Then
    If @error = 1 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Der Computer ist offline")
    EndIf
    If @error = 2 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Der Computer ist nicht erreichbar")
    EndIf
    If @error = 3 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Falsche Adresse")
    EndIf
    If @error = 4 Then
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & "IP: " & $ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4] & @CRLF & "Andere Fehler")
    EndIf
    EndIf
    $ipstart[4] += 1
    If $ipstart[4] > 255 Then
    $ipstart[3] += 1
    $ipstart[4] = 0
    If $ipstart[3] > 255 Then
    $ipstart[2] += 1
    $ipstart[3] = 0
    If $ipstart[2] > 255 Then
    $ipstart[1] += 1
    $ipstart[2] = 0
    If $ipstart[1] > 255 Then
    MsgBox(16, "Fehler", "Maximale IP-Range überschritten:"&@CRLF&$ipstart[1]&"."&$ipstart[2]&"."&$ipstart[3]&"."&$ipstart[4])
    EndIf
    EndIf
    EndIf
    EndIf
    Until $ipstart[1] = $ipstopp[1] And $ipstart[2] = $ipstopp[2] And $ipstart[3] = $ipstopp[3] And $ipstart[4] = $ipstopp[4]
    FileWrite(@ScriptDir & "/IP"&$n&".txt", @CRLF & @CRLF & "Suche beendet: " & @HOUR & ":" & @MIN & ":" & @SEC)
    MsgBox(0, "Vorgang abgeschlossen", "IP Log erstellt")

    [/autoit]
  • Danke für die vielen Ideen, ich hatte auch schon versuch mit cmd mit net session. War aber nicht so erfolgreich, die letzten beiden Scripte funktionieren sehr gut vorbei das von Xenobiologist am schnellsten ist.