Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How will i execute the Net View command prompt through coding to collect the all machine name into string array from LAN?????

anybody Please help me for above problem......
Posted
Comments
Member 7678194 24-Jan-12 4:17am    
Thank you very very much for supplying above code.
It's very useful to me.

1 solution

Hi, try the code:
VB
Function ComputerList() As String()
        Dim p As New Process
        Dim sysFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.System)
        p.StartInfo.FileName = System.IO.Path.Combine(sysFolder, "net.exe")
        p.StartInfo.Arguments = "view"
        p.StartInfo.UseShellExecute = False
        p.StartInfo.RedirectStandardOutput = True
        p.Start()
        Dim result As String = p.StandardOutput.ReadToEnd
        p.WaitForExit()
        Dim mList As New List(Of String)
        For Each line As String In result.Split(vbLf)
            If line.Length > 2 AndAlso line.Substring(0, 2) = "\\" Then
                mList.Add(line.Split(" ")(0).Replace("\\", String.Empty))
            End If
        Next
        Return mList.ToArray
    End Function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900