Christopher D Albert
Christopher D Albert

Reputation: 57

System.FileNotFound exception

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

Upvotes: 0

Views: 88

Answers (3)

Ondrej Janacek
Ondrej Janacek

Reputation: 12616

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.

Upvotes: 1

Dominic B.
Dominic B.

Reputation: 1907

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

Upvotes: 1

fejesjoco
fejesjoco

Reputation: 11903

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

Upvotes: 1

Related Questions