Getting Application path during the installation

c# get executable path
c# get install path from registry
how to find path of installed software in windows 10
custom action installer class c#
how to find installation path in windows
what is install path
how to find the path of an application in windows
installation directory

I'm deploying an application and during the installation after the user chooses where to install the app, I want to get that path; I'm in a custom action already but i don't know how to get the application path where it's going to be installed !

It's Windows Forms and I'm developing using Visual studio 2010 "C#".

And I'm using the default deploying tool...

Any idea?

thanks in advance...

The class your custom action is in should inherit from System.Configuration.Installer.Installer. This has a parameter on it called Context which has a Parameters dictionary. The dictionary contains a number of useful variables about the install and you can add some.

Once you have added the custom installer to your install project in the Custom Actions pane. Select the Install action and set the CustomActionData property to:

/targetdir="[TARGETDIR]\"

Then you can access the path like this:

[RunInstaller(true)]
public partial class CustomInstaller : System.Configuration.Install.Installer
{
    public override void Install(System.Collections.IDictionary stateSaver)
    {
        base.Install(stateSaver);
        string path = this.Context.Parameters["targetdir"]; 
        // Do something with path.
    } 
}

How do I set the default install path with a windows installer?, How do I find the installation path of an application? I want to get the installation path of all applications which are installed through MSI. I have enumerated the Registry key /HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall/and get all installed application names and installation paths of some of them.

I know it's VB but This worked for me.

Private Sub DBInstaller_AfterInstall(ByVal sender As Object, ByVal e As   System.Configuration.Install.InstallEventArgs) Handles Me.AfterInstall

    MessageBox.Show(Context.Parameters("assemblypath"))

 End Sub

Find where windows program is installed, How do I set the default install path with a Windows installer? If the application includes an installation log then it may contain the source path for the install files but the chances are slim (I've checked the install log for Firefox and it has no mention of the source file) as such I'm inclined to say it's not possible to identify the source install for your programs but you shouldn't need to know where the install files where only where the program was installed.

Sorry to post answer for old post but my answer may help other.

public override void Install(System.Collections.IDictionary stateSaver)
{
    base.Install(stateSaver);
    rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
    if (rkApp.GetValue("MyApp") == null)
    {
        rkApp.SetValue("MyApp", this.Context.Parameters["assemblypath"]);
    }
    else
    {
        if (rkApp.GetValue("MyApp").ToString() != this.Context.Parameters["assemblypath"])
        {
            rkApp.SetValue("MyApp", this.Context.Parameters["assemblypath"]);
        }
    }
}

public override void Uninstall(System.Collections.IDictionary savedState)
{
    base.Uninstall(savedState);
    rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

    if (rkApp.GetValue("MyApp") != null)
    {
        rkApp.DeleteValue("MyApp", false);
    }
}

Can i get Source Path of Installed application?, the DefaultLocation property of the Application Folder folder, within the File System Editor. This, in turn, as you've found, defaults to [ProgramFilesFolder][Manufacturer][ProductName] . I'm deploying an application and during the installation after the user chooses where to install the app, I want to get that path; I'm in a custom action already but i don't know how to get the application path where it's going to be installed ! It's Windows Forms and I'm developing using Visual studio 2010 "C#".

Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

Get Application Directory [C#], Where do I find my installed programs in Windows 10? In the Value data box, type the path of the Windows installation files, and then click OK. Right-click ServicePackSourcePath, and then click Modify. In the Value data box, type the path of the Windows Service Pack installation files, and then click OK. Locate the following registry subkey:

How To Find the Absolute Path of an Application, is there any way to know that form which path an application was installed. for example I have firefox.exe in. D:\Downloads\App\firefox.exe. and when I install it, it  This time I encountered another problem: I wanted to create a setup and deployment project which passes arguments during installation time from the user to the configuration file of my application. It took me a while but I managed to find a way to make it work.

How to install files in a custom folder, Class Application in System.Windows.Forms namespace has static property ExecutablePath. It contains path of the .exe file (that started the application)  The correct command line is:Transforms= path * transform file name *.mstThe Setup.exe log file contains the command line that you specified for the installation so that you must check the log file for typographical errors such as the one that is shown in the previous example (the letter "s" is missing from the end of "Transform" in the first command line).

How To Get Application Startup Path From The Console Application , You may have installed an application or game to your machine and forgot to install a Duration: 2:47 Posted: Dec 29, 2011 string exePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetEntryAssembly().Location); Other methods either require a library which you don't use (such as System.Windows.Forms ) or depends on how the code is hosted (for example, using parameters of Main is not reliable).

Comments
  • Based on "custom action" I'm guessing you're using Windows Installer. Are you using Wix or a Visual Studio Setup Project?
  • oh im sorry i forgot to provide more info i will edit my question...
  • My bad. You also need to set the CustomActionData property. Post updated.
  • How to use TARGETDIR in visual c++?
  • That trailing slash was making me angry... Still is. Turns out the "[TARGETDIR]\" is a quoting problem in the compile process. (Says some guy on the internet.) social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/…
  • Thank you.Recently i'd like to invoke regsvr32 command in the program, it keeps appearing "fail to load "C:\Program " module".The reason is you have to add double quote around the path,like path = "\"" + path+"\"";Cheers!
  • Still works under VS 2015. If i find the time i will create Videos showing how it's done.
  • Seems that it doesn't answer the question.
  • This question asks about working with an installer. Not how to get the path of the currently executed program.
  • @BDL No, the question asks the path of the target application being installed. For a Windows Services installer, the answer is the executing assembly as I provided.