querying netsh in c#

2019-04-16 17:28发布

问题:

I've been trying to come up with an ideal way to query WiFi information using C#. I've tried the netsh method but was unsure how to separate the information. I notice that Vistumbler uses netsh. Is there a way that these developers would have separated the information when querying netsh or have they just performed a lot of string manipulation to cut out the irrelevant stuff.

回答1:

That is what I do usually. Call netsh, get the output and parse it.

Process p = new Process();
p.StartInfo.FileName = "netsh.exe";
p.StartInfo.Arguments = "netsh arguments...";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();

string output = p.StandardOutput.ReadToEnd();
// parse output and look for results


标签: c# .net netsh