开发者

C# - Using switches when launching processes

开发者 https://www.devze.com 2023-03-13 15:52 出处:网络
I have code that launches a pr开发者_开发问答ogram: Process.Start(\"cmd.exe\", \"/c test.exe \\\"\\\" > output.txt\").WaitForExit();

I have code that launches a pr开发者_开发问答ogram:

Process.Start("cmd.exe", "/c test.exe \"\" > output.txt").WaitForExit();

Although instead I would like to use a parameter / switch with test.exe:

test.exe -F input.txt

How could this be done?


Use ProcessStartInfo.Arguments. There is an example in the msdn page.

    var process = new Process
                      {
                          StartInfo = new ProcessStartInfo
                                          {
                                              FileName = "test.exe",
                                              Arguments = "-F input.txt",
                                          }
                      };
    process.Start();
    process.WaitForExit();
0

精彩评论

暂无评论...
验证码 换一张
取 消