Open exe file from different project in same solution

Open exe file from different project in same solution

Page 1 of 1

5 Replies - 5482 Views - Last Post: 08 January 2010 - 03:16 PM Rate Topic: -----

#1 daydr3am3r  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 101
  • Joined: 10-April 09

Open exe file from different project in same solution

Posted 07 January 2010 - 04:08 PM

Well I'm sure I'm not the 1st one asking this but I just couldn't find other posts for this.
The question is simple: How do I open an .exe file from a different project but same solution.
I have a solution with 5 projects, one project is the interface that will allow me to open all the other apps.
Thanks & sorry if there is another topic for this.
Is This A Good Question/Topic? 0
  • +

Replies To: Open exe file from different project in same solution

#2 monkey_05_06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 105
  • Joined: 26-August 06

Re: Open exe file from different project in same solution

Posted 07 January 2010 - 09:46 PM

I'm not 100% sure it's what you're looking for, but I just had to use System.Diagnostics.Process.Start for launching an external EXE from my project. I believe it's under the System reference (in the Object Browser). Lots of good stuff there, I was able to launch the EXE I needed, wait for it to finish, and then continue doing what I needed. Worked well for me. :D

So try something like:

using System.Diagnostics;

	// inside your program
	Process otherApp = Process.Start("PATH_TO_EXE");


From my testing it appears that relative paths like "./app.exe" don't work but if you just do "app.exe" it will. Just FYI.
Was This Post Helpful? 0
  • +
  • -

#3 daydr3am3r  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 101
  • Joined: 10-April 09

Re: Open exe file from different project in same solution

Posted 08 January 2010 - 12:56 AM

Hi
Thanks for your reply. I already tried this. It's OK when you want to open programs already installed.
The files I want to open are not installed, they're in Visual Studio.
Check out this print screen: http://img213.images...74/capturem.png
I have 4 projects in the SAME SOLUTION. When I debug one of my projects, the generated exe is located in the default folder, \bin\debug. I can use what you said, but what happenes when create the installer and isntall the application on another PC? I need to link those files not by using a predefined path but in a dynamic way because every .exe file is the output of one project and their location can be changed.
For example, when I use a string to connect to a database I consider the project folder as the |DataDirectory| and the paths of everything in that directory change dynamically. If I try to put static paths the installer won't work.
Another weird thing is that when I use what you suggested on WinXP x86 VC#2008 + SP1 it works and on Win7 x64 same VC# it doesn't. Tried to run the app as admin but it didn't work(VS is run as admin).
Is there a way to do the same for the solution folder?
Thanks again for your reply.

This post has been edited by daydr3am3r: 08 January 2010 - 01:17 AM

Was This Post Helpful? 0
  • +
  • -

#4 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Open exe file from different project in same solution

Posted 08 January 2010 - 02:20 AM

You can't directly start executables from the same solution. You need a path to those, so if you later create an installer and you are sure that all other executables will be included in the package, then you could use something like this:

string myOtherEXE = "sample.exe";
string path = string.Format("{0}\\{1}", System.IO.Path.GetDirectory(Application.ExecutablePath), myOtherEXE);
Process.Start (path);


Was This Post Helpful? 0
  • +
  • -

#5 daydr3am3r  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 101
  • Joined: 10-April 09

Re: Open exe file from different project in same solution

Posted 08 January 2010 - 02:35 AM

View PostCore, on 8 Jan, 2010 - 01:20 AM, said:

You can't directly start executables from the same solution. You need a path to those, so if you later create an installer and you are sure that all other executables will be included in the package, then you could use something like this:

string myOtherEXE = "sample.exe";
string path = string.Format("{0}\\{1}", System.IO.Path.GetDirectory(Application.ExecutablePath), myOtherEXE);
Process.Start (path);



Thaks
I know I need a path, I was just hopeing that I can use a path that changes dynamically like |DataDirectory|\bin\debug\app.exe for example.
I'll try out your suggestion and post again.
Thanks again.
Was This Post Helpful? 0
  • +
  • -

#6 daydr3am3r  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 101
  • Joined: 10-April 09

Re: Open exe file from different project in same solution

Posted 08 January 2010 - 03:16 PM

Hi
I tried this:
			try
			{
				Process SSS = Process.Start("app.exe");
			}

			catch (Exception)
			{
				Process SSS = Process.Start("path_goes_here\\app.exe");
			}

			finally
			{

			}


and it works.
But I'm not sure it's the right way to do this.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1