querying netsh in c#
Asked Answered
P

1

1

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.

Perch answered 25/11, 2011 at 22:17 Comment(2)
What kind of information do you need from netsh ?Hillaryhillbilly
@Nacereddine im just trying to get the physical id and rssi of multiple access points. Im using 'Managed WiFi API' but wondered, since Vistumbler uses netsh if that's the best way to go.Perch
C
6

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
Clubfoot answered 25/11, 2011 at 22:22 Comment(1)
This seems like the most functional way, but be aware that the format of the arguments may be slightly different in Vista or in XP. Open a CMD window and check with netsh -? on both OSes to be sure.Nomadize

© 2022 - 2024 — McMap. All rights reserved.