问题描述
我想创建一个C#应用程序创建一个WLAN网络。我目前使用的netsh使用命令提示符。我的应用程序应该按一下按钮做到这一点。下面是我在管理模式命令提示符下使用的netsh wlan的一套hostednetwork模式=允许SSID = SHA键= 12345678之后,我输入netsh的WLAN开始hostednetwork的命令。当我做到这一点我可以创建一个无线局域网。在C#中我编写像下面
私人无效的button1_Click(对象发件人,EventArgs五)
{
流程p =新工艺();
p.StartInfo.FileName =netsh.exe中;
p.StartInfo.Arguments =WLAN设置hostednetwork模式=允许SSID = SHA键= 12345678+的netsh wlan的开始hostednetwork
p.StartInfo.UseShellExecute = FALSE;
p.StartInfo.RedirectStandardOutput = TRUE;
p.Start();
}
您应该这样做: +的Netsh WLAN开始hostednetwork
来的第一道工序的参数。这将意味着你在控制台输入这样的:
Netsh的WLAN设置hostednetwork模式=允许SSID = SHA键= 12345678netsh WLAN开始hostednetwork
相反,要为第二线的新工艺:
私人无效的button1_Click(对象发件人,EventArgs五)
{
过程P1 =新工艺();
p1.StartInfo.FileName =netsh.exe中;
p1.StartInfo.Arguments =WLAN设置hostednetwork模式=允许SSID = SHA键= 12345678;
p1.StartInfo.UseShellExecute = FALSE;
p1.StartInfo.RedirectStandardOutput = TRUE;
p1.Start();
处理P2 =新工艺();
p2.StartInfo.FileName =netsh.exe中;
p2.StartInfo.Arguments =WLAN开始hostednetwork
p2.StartInfo.UseShellExecute = FALSE;
p2.StartInfo.RedirectStandardOutput = TRUE;
p2.Start();
}
I want to create a C# application to create a WLAN network. I currently use netsh using command prompt. My application should do this in button click. Here is the command I use in command prompt in admin mode "netsh wlan set hostednetwork mode=allow ssid=sha key=12345678" after that I enter "netsh wlan start hostednetwork". When I do this i can create a wifi local area network. In C# I coded like below
private void button1_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = "netsh.exe";
p.StartInfo.Arguments = "wlan set hostednetwork mode=allow ssid=sha key=12345678"+"netsh wlan start hostednetwork";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
}
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();
}
这篇关于使用C#的Netsh命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!