# [.net] How to run an EXE from a C# project

## Recommended Posts

Hi everyone, I have built an EXE assembly and now I have created a new project from where I want to run it. Is there any way I can run the already built EXE by adding it as a reference in my current project which will in turn find its entry point and execute it as a separate process? I've already made it work using this code:
System.Diagnostics.Process process2 = new System.Diagnostics.Process();
process2 = System.Diagnostics.Process.Start(@"C:\...");


but I don't really like it as it's using an absolute path to the exe, that's why I want to add the EXE as a reference. Thank you very much

##### Share on other sites
Quote:
 Original post by Cozmozbut I don't really like it as it's using an absolute path to the exe

Application.StartupPath + "exename.exe"?

However, out of curiosity, why did you structure it like that? (two exes, one calling the other.)

##### Share on other sites
Hey, that did it :), well the reason behind the two EXEs is that I developed them separately and they can work as stand-alone applications, now I decided I could combine them into a bigger application but I don't feel up to reworking the EXE that gets called.

##### Share on other sites
Path.Combine() is probably a better bet than simply concatenating paths, as certain operating systems (eg Linux) will choke on backslashes.

Alternatively, in your case you might find AppDomain.ExecuteAssemblyByName() more appropriate.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627694
• Total Posts
2978670

• 18
• 14
• 12
• 10
• 12