Archive: Detecting Installed Application


Detecting Installed Application
I have this fragment of code that does not seem to work:

;cView Section
Section "Crystal Reports Viewer" CRViewer info
ReadRegStr $0 HKCU "SOFTWARE\Sand\Third\cView" "Installed"
IfErrors lblNoApp lblAlreadyInstalled
lblNoApp:
SetOutPath "$INSTDIR\sw\cV81"
File "sw\cV81\*.*"
ExecWait '"$INSTDIR\sw\cV81\setup.exe " /sms'
WriteRegStr HKCU "SOFTWARE\Sand\Third" "cView" "Installed"
lblAlreadyInstalled:
MessageBox MB_OK "cView already installed!"
SectionEnd

I check the value in registry and is there. If I try to run installer again it does not detect that app has been installed.

Any help is appreciated.


Why not ...


ReadRegStr $0 HKCU "SOFTWARE\Sand\Third\cView" "Installed"
StrCmp $0 "" NoInstall YesInstall
NoInstall:
;Here the code if no installed
YesInstalled:
;Here the code if installed

Make sure the error flag is clear before you execute instructions you later wish to check for errors. Use the ClearErrors instruction before ReadRegStr.


Tried both ideas did not work!
Thanks for the two ideas above but it still does not work...

;--------------------------------
;cView Section
Section "Crystal Reports Viewer" CRViewer info
ClearErrors
ReadRegStr $0 HKCU "SOFTWARE\Sand\Third\cView" "Installed"
StrCmp $0 "" NoInstall YesInstall
NoInstall:
;Here the code if not installed
SetOutPath "$INSTDIR\sw\cV81"
File "sw\cV81\*.*"
ExecWait '"$INSTDIR\sw\cV81\setup.exe " /sms'
WriteRegStr HKCU "SOFTWARE\Sand\Third" "cView" "Installed"
YesInstall:
;Here the code if installed
MessageBox MB_OK "cView already installed!"
SectionEnd


You are reading and writing from different keys.

If you are reading from here:

ReadRegStr $0 HKCU "SOFTWARE\Sand\Third\cView" "Installed"

Writing here is not the right place:

WriteRegStr HKCU "SOFTWARE\Sand\Third" "cView" "Installed"

It should be:

WriteRegStr HKCU "SOFTWARE\Sand\Third\cView" "Installed" "1"


It was better...almost there
It seems that both sections get executed (e.g. YesInstall & NoInstall)..

;--------------------------------
;cView Section
Section "Crystal Reports Viewer" CRViewer info
ClearErrors
ReadRegStr $0 HKCU "SOFTWARE\Sandvine\Third\cView" "Installed"
StrCmp $0 "" NoInstall YesInstall

YesInstall:
;Here the code if installed
MessageBox MB_OK "cView already installed!"

NoInstall:
;Here the code if not installed
SetOutPath "$INSTDIR\sw\cV81"
File "sw\cV81\*.*"
ExecWait '"$INSTDIR\sw\cV81\setup.exe " /sms'
WriteRegStr HKCU "SOFTWARE\Sandvine\Third\cView" "Installed" "1"
SectionEnd


That would be because you're not skipping NoInstall if YesInstall is executed. You should put Goto done at the end of the YesInstall part and a label called done at the end of the section.


Thanks !!
You are a genious!