This works:
Process.Start("control", "/name Microsoft.DevicesAndPrinters");
But this doesn't: (It just opens a command prompt.)
ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
info.Arguments = "control /name Microsoft.DevicesAndPrinters";
Process.Start(info);
Why?
(Yes, I know they're not identical. But the second one "should" work.)
Try this one
You need a
/c
or a/k
switch (options forcmd.exe
) so that the command is executed. Try:This is because
cmd.exe
expects a/K
switch to execute a process passed as an argument. Try the code belowEDIT: Changed to
/K
above. You can use/C
switch if you wantcmd.exe
to close after it has run the command.