2
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();
}
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364

1 Answers1

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