我很难理解为什么
IfFileExists
本质上返回 False
,即使下面 $R0
返回的卸载可执行文件 ReadRegStr
存在。
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"
更令人困惑的是,如果我将测试硬编码为
IfFileExists "C:\Program Files\App\UninstallApp.exe" ...
IfFileExists
有效回报True
!!!
更新
我可以使用
!=
运算符,但最好另外测试路径。
${If} $R0 != ""
MessageBox MB_OK "Installation file $R0 exists"
${Else}
MessageBox MB_OK "Installation file $R0 does NOT exist"
${EndIf}
注册表路径包含引号?
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
...