2012-11-30 199 views
1

我',需要檢查它是否已經安裝:Installer未利用NSIS創建安裝程序爲我的應用程序檢測到舊版本安裝NSIS

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" 
    OutFile "MyAppInstaller.exe" 
    InstallDir "$PROGRAMFILES\MyApp" 
    InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" 
    ShowInstDetails show 
    ShowUnInstDetails show 

    Function .onInit 
    ; Check to see if already installed 
     ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME} ${PRODUCT_VERSION}" "UninstallString" 
     IfFileExists $R0 +1 NotInstalled 
     Messagebox MB_ICONQUESTION|MB_YESNO "MyApp 1.0 is already installed.Do you want to uninstall old version" IDNO Quit 
     Exec $R0 
    Quit: 
     Quit 


    NotInstalled: 
     !insertmacro MUI_LANGDLL_DISPLAY 

    FunctionEnd ... 

卻沒有任何反應總是進行安裝和沒」檢測舊的安裝版本,我錯過了什麼?我不太瞭解NSIS腳本,所以任何幫助將不勝感激。

回答

2

我唯一的猜測是,你正在檢查錯誤的註冊表鍵或返回的路徑被引用和/或有參數,所以文件存在檢查失敗。

驗證與Messagebox mb_ok $R0的路徑IfFileExists前行,如果它是空的,你應該嘗試Process Monitor,它也許能夠給你一些線索......在行動

+0

是,正確的是'$ ReadRegStr R0 HKLM「Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ $ {PRODUCT_NAME}」「UninstallString」'thnak你的時間。 – Oumaya