2

I am using InstallShield 2015 and project type is basic MSI. I need to run a few different batch files during the install process as well as the uninstall process. For the install process I created a custom action to run an EXE (or batch file in my case). The working folder is the SystemFolder and the command line is the following:

"[SystemFolder]cmd.exe" /c "[INSTALLDIR]PrinterInstaller\installPrinterDriver.cmd" [INSTALLDIR]PrinterInstaller\

This works perfect during the install process. A problem occurs during the uninstall. I have another custom action for the uninstall:

"[SystemFolder]cmd.exe" /c "[INSTALLDIR]PrinterInstaller\removePrinterDriver.cmd"

This above does not work. I reviewed the log and [installdir] is returning the default path instead of the path the user chooses during the install process. So if the user accepts the default install path during installation, everthing works great. If they choose a different path, the uninstall process fails. I researched this and my mistake is that I can't use the INSTALLDIR property during uninstall as it will return the default. I've read several posts on this subject and I understand the problem. I am facing the same issue with some custom installscript that runs during the uninstall process. I solved this by using the registry to store the "user" selected install folder during install then retrieving it during the uninstall. This works. Is there a way to apply a similar technique to custom actions that run batch files? I mean, can I lookup from the registry somehow and get rid of the [INSTALLDIR] syntax in my command line.

Here is a similar post, but was not a solution for me:

Install file create by InstallShield 2012 sometimes did not get the proper INSTALLDIR when uninstall

Community
  • 1
  • 1
Jim Kennedy
  • 782
  • 9
  • 23
  • Note: I do have a custom action SetARPINSTALLLOCATION. It is being set to [INSTALLDIR] during install only (condition = NOT Installed). When I use [ARPINSTALLLOCATION] instead of [INSTALLDIR] in my command line I get an empty string. Seemed like a good option, but does not work in this context. – Jim Kennedy Nov 18 '15 at 14:42
  • Another way to pose this question would be that "I need a public property that can be referenced with the square bracket syntax that will contain the actual install directory". – Jim Kennedy Nov 18 '15 at 20:02
  • I recommend that you include all the extra info from your comments, at least the one starting with [Note:](http://stackoverflow.com/questions/33781658/installshield-running-batch-files-during-uninstall-using-installdir-property#comment55332537_33781658) in your question post... – aschipfl Nov 18 '15 at 22:33
  • When you say the other post was not a solution, does that mean you do install a file into a component with INSTALLDIR as its directory, and yet INSTALLDIR is not correct during maintenance? In the maintenance log file is INSTALLDIR is ever correct? – Michael Urman Nov 19 '15 at 12:27
  • The reason the other post is not a solution for me, is because (on top of not begin very clear) the poster is trying to get the property INSTALLDIR from within a script. In my case, I am trying to use a custom action (type 34) with bracket syntax and I need the INSTALLDIR property to expand to the correct (user selected) install path. The other poster did mention he solved his issue but he did not provide enough details. – Jim Kennedy Nov 19 '15 at 14:01

1 Answers1

0

OK, I found a solution for this. I created a system search to read the registry and retrieve a value which can be stored into a public PROPERTY. Here are the steps: 1. Create a system search (uses the AppSearch and RegLocator tables). The system search will lookup the value from the registry and store it into a new public property (i.e. REALINSTALLDIR) that I choose. 2. During install phase the correct installation path will be stored into the registry under something like HKLM\software\mycompany\myproduct. Make sure the registry path and value used here matches the path/value used in the system search. 3. Change the custom action to use the new property.

"[SystemFolder]cmd.exe" /c "[REALINSTALLDIR]PrinterInstaller\removePrinterDriver.cmd"

REALINSTALLDIR will contain the user selected path or the default if the user accepts the defaut path. This expands correctly during the uninstall phase because the system search will populate the property at runtime.

The following post was the key to my answer: http://forum.installsite.net/index.php?showtopic=10773

Jim Kennedy
  • 782
  • 9
  • 23