2015-12-08 163 views
0

在安裝新版本之前,我強制卸載以前的版本。
出於某種原因,它不適用於XP/Vista/10 x64。卸載字符串爲空。我幾乎肯定它正在查找錯誤的註冊表。有沒有辦法強制它檢查非wow64(反之亦然)?我不知道它有什麼可能。NSIS在某些x64操作系統上未檢測到以前的版本

# The ExecWait seems not to work on Windows XP x64/Vista x64/10 x64 (it seems to work fine on Vista x64/8 x64) 
${If} ${RunningX64} 
    ${GetWindowsVersion} $R0 
    ReadRegStr $R1 HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" 
    MessageBox MB_OK "You are running $R0 x64! R1 is $R1" 
    StrCmp $R1 "" no_remove_uninstaller 
${Else} 
    ${GetWindowsVersion} $R0 
    ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" 
    MessageBox MB_OK "You are running $R0 x86! R1 is $R1" 
    StrCmp $R1 "" no_remove_uninstaller 
${EndIf} 

    MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ 
    "${PRODUCT_LONG_NAME} is already installed. $\n$\nIf you have software older than XXX 1.3, please manually uninstall it with Windows before proceeding. $\n$\nClick `OK` to remove the \ 
    previous version or `Cancel` to cancel this upgrade." \ 
    IDOK uninst IDCANCEL giveup 

giveup: 
    Abort 

# Run the uninstaller 
uninst: 
    ExecWait '"$INSTDIR\uninst.exe" _?=$INSTDIR' $R1 
    StrCmp $R1 0 no_remove_uninstaller # Success? If so we are done... 
    Abort # Uninstaller was canceled or failed, we cannot continue 

被修改 - I除去上面的64位的功能。並提出你所提到的改變。由於缺少InstallString,我使用filefunc getparent函數來執行測試。這應該做的伎倆,還是我需要仍然做regview?它似乎在XP x86和7 x64上工作,儘管他們一直工作。這使得奇怪的是,在兩個操作系統之間沒有。

ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" 
${GetParent} $0 $R0 
IfFileExists "$R0\uninst.exe" 0 no_remove_uninstaller 
ExecWait '"$R0\uninst.exe" _?=$R0' $R1 
StrCmp 0 $R1 0 giveup 
Delete "$R0\uninst.exe" 
RMDir "$R0" 

其他更新:它仍然無法在Vista x64和XP x64的工作。其他類型的Windows現在都可以使用。

最後更新我覺得現在的工作...我換從32regview 64,因爲我的我在做什麼逆轉思維。

+0

你在64上安裝64位特定組件位版本的Windows?如果沒有,爲什麼你有64位特定的代碼呢? – Anders

回答

1

你的代碼沒有意義。

您正在檢查${RunningX64},但仍然強制它訪問註冊表的32位部分。除非您使用SetRegView 64,否則32位安裝程序將始終從註冊表的32位部分讀取。

更大的問題是,在運行先前版本的卸載程序時,必須使用先前版本的路徑,而不是$ InstDir!如果您的舊版本寫入InstallLocation值,則可以使用該值,否則您必須從UninstallString值中提取路徑。最重要的部分是要記住的是,以前的安裝可能會在不同的目錄,你最終安裝到,所以你也必須做一些額外的清理一個:

ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "InstallLocation" 
IfFileExists "$0\uninst.exe" 0 no_previous_version 
ExecWait '"$0\uninst.exe" _?=$0' $R1 
StrCmp 0 $R1 0 uninst_aborted 
Delete "$0\uninst.exe" 
RMDir "$0" 
+0

我的卸載部分中也沒有'installpath'。這可以通過使用uninstring並從字符串中刪除'\ uninst.exe'來緩解。但我也失去了對話框,但我認爲這是多餘的。 –

相關問題