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

后端 未结 1 615
北荒
北荒 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)
提交回复
热议问题