Command netsh using C#

家住魔仙堡 提交于 2019-12-01 13:58:38

You shouldn't do this: +"netsh wlan start hostednetwork" to the arguments of the first process. That would mean that you are typing this at the console:

netsh wlan set hostednetwork mode=allow ssid=sha key=12345678netsh wlan start hostednetwork

Instead, make a new process for the second line:

private void button1_Click(object sender, EventArgs e)
{
     Process p1 = new Process();
     p1.StartInfo.FileName = "netsh.exe";
     p1.StartInfo.Arguments = "wlan set hostednetwork mode=allow ssid=sha key=12345678";            
     p1.StartInfo.UseShellExecute = false;
     p1.StartInfo.RedirectStandardOutput = true;
     p1.Start();

     Process p2 = new Process();
     p2.StartInfo.FileName = "netsh.exe";
     p2.StartInfo.Arguments = "wlan start hostednetwork";            
     p2.StartInfo.UseShellExecute = false;
     p2.StartInfo.RedirectStandardOutput = true;
     p2.Start();
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!