0

所以我试图用它似乎有的唯一开关(/computer:\)自动启动 mmc compmgmt.msc。它可以在本地运行框中正常工作,但不能通过使用 Process.Start。这是违规行:

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

有任何想法吗?我也尝试过使用@,结果相同,所以它似乎不是转义字符问题......这是别的......

请注意:堆栈溢出修改了上述文本字符串中的转义字符。他们在那里

4

3 回答 3

1

命令和参数必须作为单独的参数传递。使用这个重载

于 2014-01-21T18:05:02.960 回答
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.

于 2014-01-21T18:07:13.720 回答
1

您必须使用单独的参数,这根本不起作用。Process.Start有一个重载来执行此操作。

于 2014-01-21T18:06:40.967 回答