views:

62

answers:

1

Hello, How to check that oldest version of application was installed during process of installation new version? What do I mean? I want before start installation start check process with dialog "please wait", if my installation found old version I can provide dialog "update or delete old and install new". How can I do it? Thanks.

+3  A: 

I'm not sure whether this can be done at all, as running an InnoSetup-setup always assumes that you want to install new or update an existing installation. I don't think you can switch a setup from "installation mode" to "uninstallation mode" upon user's choice as you'd like it to do.

InnoSetup works differently than Windows Installer at that point. It has a separate installer and uninstaller as opposed to Windows Installer, which "contains both".

If you want that feature, you may want to look into Windows Installer XML (WiX), which creates MSI setups and can do exactly what you're looking for.

EDIT
First of all, thanks for the downvote. I don't quite know why anybody would downvote a perfectly reasonable reply, but I guess I'll have to cope with it.

To answer your comment about BeforeInstall: If you read the documentation you will notice that BeforeInstall is called before an item is installed. Quote from docs:

The name of a function that is to be called once just before an entry is installed

What you want to do comes down to:

  1. Decide whether the user should be able to choose if he wants to install or uninstall when setup is run
  2. install or uninstall depending on user's choice

What I'm trying to say is that as far as I know you can not switch from installation mode (setup.exe is run) into uninstallation mode (uninstall.exe is run) from your installation script.

InnoSetup assumes that running Setup.exe is equivalent to wanting to installing or upgrading. I the user had wanted to uninstall, he would have run the uninstaller, not the setup.

Thorsten Dittmar
ok, but what about BeforeInstall in the innosetup ?
jitm
Thorsten, it would probably be possible to check in `BeforeInstall` whether the app is already installed, and if so ask the user whether to update or to uninstall. In the latter case the uninstaller could be executed and the installation be cancelled. Having said that, I completely agree with your sentiment that this is somewhat outside of the Inno Setup routine, and that there are better solutions if one wants to accomplish something like this.
mghie
If you try that I wouldn't do it in BeforeInstall, but in InitializeSetup(), which decides in general whether the setup should run or not.
Thorsten Dittmar