I need to write a program that displays this information:
- netstat
- TCP / UDP connections
- Information about the IP ipconfig /all
- arp-a
- route print
I already have most of them, but I have a problem with the route print and arp -a. I do not want to execute this command using Process.Start() because it does not look too spectacular:
Process p = new Process ();
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "route";
p.StartInfo.Arguments = "PRINT";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.StandardOutputEncoding = Encoding.Default;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();
TextBox1.Text = p.StandardOutput.ReadToEnd();
I would like to use a foreach loop to get the data into ListView or DataGrid columns. Has anyone ~ t be able to help me? How can I get this data into each column: Destination, Netmask, gateway, interface, metrics and permanent route? And in the case of ARP,
Internet address type of physical address?
I suppose you could probably just parse the text you retrieve to get out the values you want and put them in the
ListViewetc. However, I think that there are better ways to retrieve this and I think you’d be able to get out this information using the WMI class Win32_IP4RouteTable.If you haven’t used WMI before, you might be able to use the WMI Code Creator v1.0 to help you get started (I haven’t used it myself, but I saw someone else suggesting it sometime).
The WMI .NET Overview would probably be useful too.