private void start_Click(object sender, EventArgs e)
{
Process proc = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.FileName = "cmd.exe";
psi.Arguments = "netsh wlan start hostednetwork";
proc.StartInfo = psi;
proc.Start();
}
Asked
Active
Viewed 73 times
2

Soner Gönül
- 97,193
- 102
- 206
- 364

Oyeleye Osuolale
- 41
- 1
- 4
1 Answers
2
To make cmd execute the command, you have to use the /C
option.
psi.Arguments = "/C netsh wlan start hostednetwork";
But you shouldn't really need to involve cmd.exe at all. netsh
is an executable in itself, so you can invoke it directly.
psi.FileName = "netsh.exe";
psi.Arguments = "wlan start hostednetwork";

Anders Abel
- 67,989
- 17
- 150
- 217
-
1If anyone wondering; [What does cmd `/C` mean?](http://stackoverflow.com/questions/515309/what-does-cmd-c-mean) – Soner Gönül Oct 12 '15 at 06:49