Tutorial :Start another EXE in Managed Code


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


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

Thanks! JFV


            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.


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.


Use relative paths and it should work.


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  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »