Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
651 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

; Check to see if already installed
  ReadRegStr $R0 HKLM "SOFTWAREMicrosoftWindowsCurrentVersionUninstall<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:

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...