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 64 times
2
Soner Gönül
- 94,086
- 102
- 195
- 339
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
- 66,163
- 17
- 148
- 213
-
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