Alle Computer in Netzwek auflisten

  • Allgemein

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von pc-freack.

    So mach ich das:

    VB.NET-Quellcode

    1. Private Function GetComputerFromNetwork() As List(Of String)
    2. Const Argument As String = " view"
    3. Try
    4. Dim TList As New List(Of String)
    5. Dim hProcess As Process = New Process()
    6. With hProcess.StartInfo
    7. .FileName = "net.exe"
    8. .Arguments = Argument
    9. .RedirectStandardOutput = True
    10. .UseShellExecute = False
    11. With hProcess
    12. .Start()
    13. .WaitForExit()
    14. Dim result As String = ""
    15. While .StandardOutput.Peek > -1
    16. result = .StandardOutput.ReadLine()
    17. If result.StartsWith("\\") = True Then
    18. TList.Add(result)
    19. End If
    20. End While
    21. End With
    22. End With
    23. Return TList
    24. Catch ex As Exception
    25. MessageBox.Show(ex.Message.ToString(), "Info - " & MethodBase.GetCurrentMethod().Name())
    26. End Try
    27. Return Nothing
    28. End Function


    Und so rufe ich das glaub ich auf:

    VB.NET-Quellcode

    1. Dim TList As New List(Of String)
    2. TList = GetComputerFromNetwork()
    3. If TList IsNot Nothing Then
    4. For Each items As String In TList
    5. netztwerk.ListView1.Items.Add(items)
    6. Next
    7. End If


    Alle Computer werden dann im Netztwerk in einer listview mit dem Computernamen aufgelistet