4

I currently have a functioning program that simply launches a separate .exe file by clicking a button. The installer I've created asks where they want to install which by default is in fodler C:\Program Files\PRHA.

The code that launches the programs looks like this

private void ivClick(object sender, RoutedEventArgs e)
{
    Process.Start("C:/Program Files/PRHA/IV/IV.exe");
}

How can I have Process.Start find the path of the running application, so if the user decides to install in another directory, Process.Start will still work.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dylan Banta
  • 165
  • 1
  • 2
  • 17

2 Answers2

2

In the event that you just want to get the path of the running application to launch a secondary application (in the same directory) you should be able to use:

System.Reflection.Assembly.GetExecutingAssembly().Location

Reference:
http://msdn.microsoft.com/en-us/library/aa457089.aspx
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.location(v=vs.110).aspx

Seymour
  • 7,043
  • 12
  • 44
  • 51
0

I think if you do it this way then there is no need that both have to be in the same location.

We can try having a custom action on the installer of IV.exe that makes a registry entry of the installed path. And whichever is the application that needs to invoke IV.exe will read the registry and gets the path with that specific key.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kishore V M
  • 818
  • 6
  • 13