Is it possible to run a custom action only in repair mode - installation

I need to run a custom action only during Repair. But I didn't find a valid condition to do so.
If I specify a custom action with below condition, it runs in Modify mode as well as in Repair mode.
Installed AND Not REMOVE
I am using InstallShield 2012 spring.

Check the REINSTALL property. Conditional statement on your custom action should look like REINSTALL<>""

REINSTALL="" will be evaluated to True during the install and uninstall phases so the exact condition is (Installed and NOT REMOVE) AND (REINSTALL="")
because (Installed and NOT REMOVE) is True during Modify and repair operations but during repair REINSTALL property will be set to blank

For future reference check these cheat sheets:
Installshield condition cheat sheet.
How to add a WiX custom action that happens only on uninstall (via MSI)?
I have not had the time to go through all these conditions and test them, but the latter table looks reasonable at face value. However:
I believe REMOVE can sometimes be set during installation for example (and change) - it is very complicated to deal with all permutations of possibilities since MSI's command line interface and property configuration is so flexible.
The Installshield cheat sheet I have never actively used or checked. Please check their suggestions for repair - there are different ones depending on how the repair is invoked.
Please remember to also check self-repair - just delete the main application EXE and trigger self-repair by then invoking the application's advertised shortcut (if any). It has been years since I checked, but self-repair may only run actions between InstallInitialize and InstallFinalize.

Related

Custom Action - Only uninstall if installed

I have a Windows Installer project attached to my solution, which allows the user to optionally install two components of the application (they are Windows Services) using a "Checkboxes" dialogue box which I've added to the User Interface, and then Conditions on the Custom Actions...
i.e. in Custom Actions / Install I have
Primary output from ProjectA (Active)
- Condition = PROJECTACHOSEN (i.e. the Checkbox1Property value)
Primary output from ProjectB (Active)
- Condition = PROJECTBCHOSEN (i.e. the Checkbox2Property value)
In Custom Actions / Uninstall, I've added the same two "Primary Outputs".
The problem is, if during installation the user only chose one of the two projects then the uninstaller still tries to uninstall both of services, and of course throws an error when it doesn't find the missing one, causing the uninstall to fail.
What condition can I add in Uninstall to only install the service if it's currently installed?
I've tried:
adding the same conditions as the Install - this doesn't remove the services at all (presumably because you're not ticking the boxes during uninstallation)
Condition = "Installed" which I came across elsewhere on the web. This appears to be ignored and the uninstaller still tries to uninstall both services.
you can use ?ComponentName to check install state of a component, i used it similarly few months ago.
Ive found about it in cheat sheet from flexera here
The best solution I've managed to come up with so far is:
Add a File Search "Launch Condition" for each project that checks for the existence of the .exe file that is the service, and give it a "Property" value.
Use the property value as the "Condition" of the Custom Action.
This works but I'm not totally happy with it, as it's more important that the service is deleted than the exe and if the exe goes missing it won't work and the service will remain...
Edit
Even that doesn't work unless I set the Search "Depth" to at least 3 (even though the exe file is in the installation directory and the "Folder" set to [TARGETDIR]), but if I do that, the installer takes about 20 seconds just to start up - presumably because of the time it takes to search 3 levels of subdirs. But if I set to any less than that although the installer starts quickly it now doesn't seem to find the exe and doesn't uninstall the service...
Shouldn't [TARGETDIR] reflect my installation directory and therefore work with a depth of 0?

how to get the name of the feature being installed using wix managed bootstrapper ui

I am using WiX to install a executable and I have used ManagedBootstrapperApplicationHost for CustomUI.
Is it possible to get the name of the feature being installed at the time of installation ?
If possible then how can we get the name of the feature ?
Any help would be appreciated.
Thanks.
Features aren't installed one after another. For example if 3 features are being installed, each with 10 files then the InstallFiles action will install all 30 files at the same time. Same thing with registry entries. So you can't display a UI that says "Installing Feature1" and then later on "Installing Feature2" because that doesn't happen. All you can know is that some list of features are being installed.
Your comment asks about finding out whether a feature installed successfully or not. This issue never comes up - there are never some features that install and others that fail. An MSI install is a transaction and it either all works or fails and rolls back and deletes changes it made so that the system is restored to its previous state.
It's not clear why the list of features is so important to display. If you use the MSI's internal UI there is a feature selection dialog where the user selects which features are to be installed; if you use the Burn UI the same thing is available, so the user can see what features have been chosen.
Inside the MSI the list of features being installed (after they've been selected) is in the ADDLOCAL property, but that's the internal name. It could be used to display a list of the features that were installed at the end, but again by definition what was chosen is installed otherwise the install would have rolled back entirely. I don't believe I've ever seen an install where the list of MSI features installed is displayed at the end - it's redundant info. It would be useful to know the scenario you have, or what problem you're trying to solve, and if you believe that you need to display a list because some might install and others might fail then there is no point, as I have said.

Remove InstallShield prerequisites if installation cancelled

We use InstallShield 2010 to install our software using the InstallScript approach. There are some prerequisites that may be installed as necessary. In the OnBegin callback, we execute some logic to validate the system before continuing with the installation. If the user cancels the installer at this point, the installation will exit, but the prerequisites are not uninstalled. I have a few questions.
1) Is it possible to perform our custom validation before the prerequisites are ever installed? This doesn't appear possible within InstallShield 2010 based on everything I've read, but I'd like to have that confirmed.
2) Is there a way to force the prerequisites to be uninstalled if the user cancels the installation?
3) Are there alternatives that would allow the prerequisites to be installed after the OnBegin callback? I read something about prerequisites being tied to a particular feature, but it is unclear how to do this in the UI.
1) The answer to your first question is also probably the easiest most plausible solution. You should be able to get your custom validation to run before the other prerequisites by creating your own prq file with all the custom validation logic wrapped up into it. To create your own .prq file you can just copy an existing prq in the SetupPrerequisites folder and rename it. Then open the Redistributable view in InstallShield. The copied/renamed .prq file should now show up in the list, and you can right click and select Edit Prerequisite. Then change the Properties,Conditions,Files To Include,Application To Run, etc.
For example, suppose your validation is an executable that runs and sets a registry key depending on success. You could check if the registry key exists as a condition of whether to run the prerequisite, include the exe and any dependencies in the Files to Include tab, run that executable in the Application to Run tab, and in the Behavior tab set the drop down of what happens if the launch conditions are still not met to Abort the setup
After you're satisfied with all your prerequisite settings, right click again and select Set prerequisite order... and make sure that your custom validation prerequisite is at the top of the list.
2) Yes, there is probably a way to run some custom actions that will ensure all your prerequisites get uninstalled on a rollback, but that seems complicated and I personally wouldn't recommend it. What if the user already had the prerequisite installed on their machine and then they aborted your install and it uninstalled software they already had on their machine? They may not be too happy about that.
3) Not totally sure about this, but I don't think it's possible to have the OnBegin function execute before the prerequisites run. I say that because normally the prerequisites are launched outside of the MSI execution by a Setup.exe or something similar, at least from my understanding. Then the MSI is launched after the prerequisites complete. If the OnBegin runs as part of the MSI execution (which I believe it does) then it can't be launched before the prerequisites are launched.
Suite and Suite/Advanced UI projects available in newer versions of InstallShield handle this more directly, but how about putting OnBegin before OnBegin by wrapping one InstallScript installation in another?
Regarding your other sub-questions...
Prerequisites are handled in a fire and forget manner, and are designed to install things that may have already been present (and skip the installation in that case), so there's no direct support for uninstalling them.
Feature prerequisites are available in Basic MSI projects. For InstallScript projects, you are encouraged to use script code including LaunchApplication or similar approaches, however this can end up requiring reimplementing a prerequisite-style architecture if you don't just launch another InstallScript installation.

WIX removefiles and Windows delete registry entry

I’m been wondering during uninstall, how to control the sequence of removefiles and Windows delete registry entry through WIX.
One of my program's registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\GUID\Transforms
is deleted before removefiles. If then removefiles failed, the uninstall process abort. But the registry is already deleted, that would be a disaster。
I would recommend adding a new custom action that will be scheduled to run after removefiles during uninstallation and that will clean up the registry as you need. At the same time you will need another custom action that will be scheduled to run during installation and that will create the registry entries. Therefore you would have to remove your registry definitions out of WiX XML.
The custom actions can be written even as shell commands I believe. Otherwise writing C# custom actions is also a good option.
Please don't forget when creating the conditions when to run the custom actions on cases as minor/major upgrades and repair. Fiddling the right conditions might be quite tedious. However all this really depends on your installation scenarios.

Pre-requisite and Launch condition

I am having a small problem regarding pre-requisites and launch condition for setup.
For example, my setup is having one launch condition requiring "Software1" and one prerequisite installing "Software2".
So, if a system does not have both requirements "Software1" and "Software2" on installing the setup:
Is it shows the prerequiste dialog for "Software2"
Is it shows the launch codnition for "Software1".
I am observing the behaviour that I am getting a prerequiste dialog box using my setup.
Is there any way to set the order or to show the launch condition as first dialog while installing the setup?
If you are using InstallShield prerequisites in your installation, they will be installed by the setup.exe, not the MSI. Launch conditions are handled by the MSI, which will not be run until after the prerequisites are installed. Basically, this means that you can't show launch conditions until after prerequisites have been installed.
That being said, you may be able to configure the conditions on the prerequisites in such a way that the prerequisites would not be installed if you know in advance if a launch condition cannot be satisfied. The net effect of this is that the launch conditions are shown without installing prerequisites, but this isn't a really simple way to achieve this.
In InstallShield 2009, you can configure "feature prerequisites" that will not be installed until after features have been selected. In this case, prerequisites associated with selected features will be installed at the end of the Install UI sequence, or, if the installation is being run without a UI, just before the Install Execute sequence.
without more detail on what sort of installer system you're using, it is going to be hard to help. Assuming you're using the built-in stuff in visual studio, look on google for visual studio msi custom actions. I believe one of the allowable actions is to start another executable.
Assuming you're using MSI launch conditions, you cannot tell which order launch conditions will be evaluated.
If you do need to check something in a specific order, you'll need to use a Custom Action rather than a launch condition.

Resources