1
votes

In a standard Setup project for a WinForms app I would like to programmatically change the default installation folder (i.e. do this when the installation happens).

Is there a way to do this? I thought using a custom Installer class might hep me with this but it seems by the time it gets to any custom actions in that class, the install folder has already been selected.

1
Yes what custom installer are you using.. have you looked into Creating .MSI project for your C# winForms application.. - MethodMan
Yes--I have created an MSI project. I want to customize the default installation location programmatically at the time the installer is running. - Fernando
I created a subclass of System.Configuration.Install.Installer - Fernando
are there some Actions that you can add to this If I am not mistaken you can change the default to be what ever it is you want and or be overridden via a config file. I have done this before but it was about a year ago and I don't have the code here with me ..it's at home.. - MethodMan

1 Answers

2
votes

I had the same problem. Here Is my solution. I created an additional project, which called Win msi intaller, and add the TARGETDIR property's value as an argument.

    static void Main()
    {
            Process setupProcess = new Process();
            string msiFilePath = @"c:\path to msi package";
            string targetDir = @"target dir path";
            setupProcess.StartInfo.FileName = @"msiexec.exe /i " + msiFilePath + " TARGETDIR=\"" + targetDir + "\"";
            setupProcess.StartInfo.UseShellExecute = false;    
            setupProcess.Start();
   }

Then you should run this program to install your msi package.