0

So I am trying to automatically launch mmc compmgmt.msc with the only switch it seems to have (/computer:\). It works just fine from a local run box, but not by utilizing Process.Start. Here is the offending line:

Process.Start("mmc c:\\windows\\system32\\compmgmt.msc /computer:\\\\" + computerNameTextBox.Text.ToString());

Any ideas? I've tried using @ as well, with the same results, so it doesn't seem to be an escape character issue...it's something else...

PLEASE NOTE: stack overflow modified the escape characters in the above text string. They are properly there

Muhammad Umar
  • 3,761
  • 1
  • 24
  • 36

3 Answers3

1

The command and arguments must be passed as separate parameters. Use this overload.

fejesjoco
  • 11,763
  • 3
  • 35
  • 65
  • I facepalmed so hard ha ha ha. Thank you, my good sir. When SO allows it, I will accept this as an answer. Been grinding this code for a good solid 36 hours, kinda getting tunnel vision. – Christopher D Albert Jan 21 '14 at 18:08
1

You have to use separate parameters, this will not work at all. Process.Start has an overload to do this.

Dominic B.
  • 1,897
  • 1
  • 16
  • 31
1

You use the Process.Start() method incorrectly. It should look like this

var startInfo = new ProcessStartInfo("mmc");
startInfo.Arguments = "c:\\windows\\system32\\compmgmt.msc /computer:\\\\" 
                       + computerNameTextBox.Text.ToString();
Process.Start(startInfo);

For more information, look at this SO question.

Community
  • 1
  • 1
Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93