I am struggling to understand why IfFileExists
essentially returns False
even though the uninstall executable file $R0
returned by ReadRegStr
below exists.
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString"
IfFileExists $R0 FileExists FileDoesNotExist
FileExists:
MessageBox MB_OK "Installation file $R0 exists"
FileDoesNotExist:
MessageBox MB_OK "Installation file $R0 does NOT exist"
What's even more confounding is that if I hardcode the test to
IfFileExists "C:\Program Files\App\UninstallApp.exe" ...
IfFileExists
effectively returns True
!!!
Update
I could use the !=
operator but it would be nice to additionally test the path.
${If} $R0 != ""
MessageBox MB_OK "Installation file $R0 exists"
${Else}
MessageBox MB_OK "Installation file $R0 does NOT exist"
${EndIf}
The registry path contains quotes?
Function PathRemoveQuotes
Exch $0
Push $1
StrCpy $1 $0 1
StrCmp $1 '"' 0 done
StrCpy $1 $0 1 -1
StrCmp $1 '"' 0 done
StrCpy $0 $0 -1 1
done:
Pop $1
Exch $0
FunctionEnd
...
ReadRegStr $R0 ...
Push $R0
Call PathRemoveQuotes
Pop $R0
${If} ${FileExists} $R0
...