Can you execute another EXE file from within a C# console application?

后端 未结 1 613
北荒
北荒 2020-12-08 10:14

Can you execute another EXE file from within a C# console application?

  • Can you pass arguments?
  • Can you get the exit code back?
相关标签:
1条回答
  • 2020-12-08 10:58

    Like this:

            var proc = new Process();
            proc.StartInfo.FileName = "something.exe";
            proc.StartInfo.Arguments = "-v -s -a";
            proc.Start();
            proc.WaitForExit();
            var exitCode = proc.ExitCode;
            proc.Close();
    
    0 讨论(0)
提交回复
热议问题