Reputation: 4084
How to call an exe, generated from one c# file, from another c# file?
Upvotes: 2
Views: 1368
Reputation: 17973
If you want to generate the C# file before executing it you can use the CSharpCodeProvider to compile the C# file, and then use the Process class to execute the output file.
You can find examples of each in the provided links.
Upvotes: 0
Reputation: 129832
using System.Diagnostics;
string command = @"C:\tmp\myExe.exe -my -params";
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command)
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (Process proc = new Process())
{
proc.StartInfo = procStartInfo;
proc.Start();
return proc.StandardOutput.ReadToEnd();
}
Upvotes: 3
Reputation: 4338
System.Diagnostics.Process.Start("Path to any file, including exes");
Upvotes: 1