views:

239

answers:

4

Is it possible to start another EXE in Managed Code? At this time, all I can do is use:

System.Diagnostics.Process.Start(exeName)

Is there another way to call another EXE within the same project?

Thanks! JFV

+1  A: 

Use relative paths and it should work.

Daniel A. White
+3  A: 

You could use Assembly.ExecuteAssembly if it is managed. This will execute the main entry point in your current process instead of spinning up a new process.

Mo Flanagan
+7  A: 
            Process process = new Process();
            process.StartInfo.FileName = "c:\test.exe";
            process.StartInfo.Arguments = "/e /s";
            process.Start();

This way you get a lot of options for your process such as process.WaitForExit() so you may not run asynchronously your process, etc.

Konstantinos
I use this method for a few testing projects we have set up.
chills42
Thanks! I will check this out!
JFV
A: 

Relative paths use the CurrentDirectory, a user can easily change this when launching your app and it can change during execution. I'd recommend using something you can be certain about:

There's a lot of different ways to get your executable's path:

AppDomain.CurrentDomain.BaseDirectory

Assembly.GetExecutingAssembly().Location
Matthew Brindley