Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting if a program is already installed with NSIS

I'm using NSIS to create an installer for a program, what is the best way to detect if this program is already installed? Also, since I'm running the installer from the autorun.inf, can I immediately quit the installer if it locates an installed copy? Is there a better way to do this?

like image 951
Abdullah Jibaly Avatar asked Jan 28 '09 18:01

Abdullah Jibaly


1 Answers

How about this. I had this in an old NSIS script laying around.

; Check to see if already installed
  ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\<YOUR-APP-NAME>" "UninstallString"
  IfFileExists $R0 +1 NotInstalled
  messagebox::show MB_DEFBUTTON4|MB_TOPMOST "<YOUR-APP-NAME>" \
    "0,103" \
    "<YOUR-APP-NAME> is already installed." \
    "Launch Uninstall" "Cancel"
    Pop $R1
  StrCmp $R1 2 Quit +1
  Exec $R0
Quit:
  Quit

NotInstalled:
like image 51
Magnus Johansson Avatar answered Sep 28 '22 05:09

Magnus Johansson