I'm working on a application to start a hotspot in windows 10 using C# and netsh. So far it seems to be working just fine but I would like to get some info from as well.
private void Rfsh_Click(object sender, EventArgs e)
{
ProcessStartInfo Netinfo = new ProcessStartInfo("cmd");
Netinfo.UseShellExecute = false;
Netinfo.RedirectStandardOutput = true;
Netinfo.CreateNoWindow = true;
Netinfo.RedirectStandardInput = true;
var proc = Process.Start(Netinfo);
proc.StandardInput.WriteLine("netsh wlan show hostednetwork | findstr -i ssid");
proc.StandardInput.WriteLine("netsh wlan show hostednetwork | findstr -i status");
proc.StandardInput.WriteLine("exit");
string netoutput = proc.StandardOutput.ReadToEnd();
Rtxt.Text = netoutput;
}
As you can see from the code above I'm trying to get the ssid and hotspot status to post to Rtxt.txt and it does along with the Microsoft header and the users path.
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Users\David\documents\visual studio 2010\Projects\NetShare\NetShare\bin\Debug>netsh wlan show hostednetwork | findstr -i ssid
SSID name : "Testing"
BSSID : 52:53:49:8c:f8:4f
C:\Users\David\documents\visual studio 2010\Projects\NetShare\NetShare\bin\Debug>netsh wlan show hostednetwork | findstr -i status
Hosted network status
Status : Started
C:\Users\David\documents\visual studio 2010\Projects\NetShare\NetShare\bin\Debug>exit
How would could I go about displaying just the ssid and the status without all the other stuff. I was thinking about saving the output to a text file and pulling just the lines that began with SSID name, BSSID and Status but there has to be a more simpler method.