0

I'm creating an MSI installer for a program and want to allow people to upgrade their installation instead of always uninstalling/reinstalling.

I've gotten most of it down, but now I want to automatically set the TARGETDIR (or install directory) to be wherever the user had previously installed the application.

In Visual Studio, under Launch Conditions -> Search Target Machine, I find a registry entry named ISUPGRADE that contains the previously installed location (if it's installed), but has a /bin/XXXX.dll appended to it. I want to remove the end of this string and set it as the TARGETDIR so that the upgrade will install there.

I can set a static string in as TARGETDIR (in CustomActions and referencing the action in InstallExecuteSequence and InstallUISequence) but I'm stuck as to how to set it with my variable.

How can I do this? I'm using Visual Studio to produce the .msi file and a Powershell script (Orca for manual/testing edits) to make changes to the file.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • Basically a duplicate of https://stackoverflow.com/questions/48273612/install-files-to-existing-programs-install-path-with-visual-studio-setup-project – PhilDW Feb 28 '18 at 21:15
  • Similar, but slightly different. It sounds like they wanted to get the registry value, I already have the value and just need to modify the string slightly. I ended up using a custom action type 38 (inline VBscript) to edit the string value before using it to set my TARGETDIR – user1586574 Mar 03 '18 at 03:16

1 Answers1

-1

Split-Path

The Split-Path cmdlet returns only the specified part of a path, such as the parent folder, a subfolder, or a file name

Get-Help Split-Path

ps1psm1
  • 144
  • 4
  • Thanks, that does look useful, but I don't think that I can do this in the powershell script. I need this to run in the installer itself so that it gets the previously installed directory on the user's computer. The powershell script just edits the .msi locally on my machine before it gets published. – user1586574 Feb 27 '18 at 19:32