0

I am using inno setup script. I am trying to accomplish next:

  • To allow only one instance of setup
  • If previous version is detected allow and perform uninstall of previous version - perform this with first setup that user started.

I've tried with appMutex and that does prevent more that one instances of setup, but since I have code that detects previous version of my app, when the previous version is detected inno will ask if I want to remove previous version and when I try to do that - because of mutex - I get a message that previous instance is already running and to close previous instances.

Now if I remove mutext I can uninstall previous version but multiple instances of same setup can be started which is something I don't want.

I also tried with this link: http://www.vincenzo.net/isxkb/index.php?title=Only_one_installer_instance but it doesn't work for some reason.

and also tried with this one: http://www.codenewsfast.com/cnf/article/0/waArticleBookmark.6313056 but I get the error: cannot import dll

Is this possible at all what I am trying to accomplish?

If it is can someone help me with some solution?

Thanks for helping me with this one

  • I'm not quite sure about your second requirement. What do you mean by *"allow and perform uninstall of previous version - perform this with first setup that user started"* ? If you'll meet the first requirement and won't allow to start another instance of the setup, the installation must naturally run only by the first (and only) instance. Or am I missing something ? – TLama Dec 05 '14 at 01:59
  • You are right, but the problem is when uninstall is started it is counted as second instance of setup and that's why I cannot proceed with uninstall of previous version. – Miloš Đošović Dec 05 '14 at 02:06
  • Sorry, but I still don't understand. For now I can tell you just that the code from those articles is not well written and that in these days you don't need to use Windows API for that. Inno Setup provides the two necessary mutex functions. Here is [`an example`](http://pastebin.com/eQCcvHaR) which I was going to post as an answer, but I'm a bit lost from that second requirement. Something tells me that you want to prevent running installer when another installer or uninstaller instance of the same setup is running, but I'm not sure. – TLama Dec 05 '14 at 02:19
  • It's still the same. I cannot uninstall the previous version from first instance of setup that I started for installation. I get the message Uninstall has detected that app is currently running. Please close all instances of it now, then click Ok, or Cancel to exit. And app is not running, somehow the setup is recognized as already running instance and it looks like that starting uninstall is counted as second instance. – Miloš Đošović Dec 05 '14 at 02:27
  • That message is shown when your app. is running (when an `AppMutex` mutex exists - a mutex which your application creates) and has nothing to do with the setup instances. I clearly missed the point of this question. I thought that you want to prevent running more than one instance of the setup at the same time (which your first point *"allow only one instance of setup"* says). Well, I'm sorry, I've read your question 6 times but I'm out of ideas what do you want to do. – TLama Dec 05 '14 at 02:53
  • Btw. [`do you really need all that uninstall hell`](http://stackoverflow.com/questions/27289545/inno-setup-registry-uninsdeletekey-exclude-upgrade#comment43049390_27289545) :) ? – TLama Dec 05 '14 at 02:56
  • Well the problem is that my app is not running. That's why I am trying to tell you :) Only setup is running. You think that can be a problem with uninstall hell that I am trying to accomplish? :) – Miloš Đošović Dec 05 '14 at 03:49
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/66235/discussion-between-milos-dosovic-and-tlama). – Miloš Đošović Dec 05 '14 at 03:53

0 Answers0