Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Application path during the installation

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...

like image 780
Stacker Avatar asked Oct 13 '10 15:10

Stacker


People also ask

What is software installation path?

The typical path is normally in Windows 32-bit is C:\Program Files and in Windows 64-bit is C:\Program Files and C:\Program Files(x86). Microsoft recommends the C:\Program Files folder for the default installation destination.

How do you find out where a program is installed Windows 10?

Select Start > Settings > Apps. Apps can also be found on Start . The most used apps are at the top, followed by an alphabetical list.

How do I find my installation path?

To find the installation folder of a program using a desktop shortcut: From your desktop, right-click on the program's shortcut. Click on the Properties, and the Properties window should now be displayed. Click on the Shortcut tab, and you will find the installation path in the Target field.

How do I find the path of a Windows app?

Viewing the location of programs and apps downloaded from the Microsoft Store. Programs and apps downloaded from the Microsoft Store are installed in the following path by default: C:/Program Files/WindowsApps (Hidden items). To check hidden items, open This PC, click View and select Hidden items.


1 Answers

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.
    } 
}
like image 195
Martin Brown Avatar answered Sep 19 '22 01:09

Martin Brown