如果使用NSIS已经存在安装程序的先前版本,如何删除它

时间:2019-01-18 10:42:11

标签: nsis

如果使用具有自定义屏幕的NSIS(如下面所示)通过提供“更改”,“修复”和“删除”选项,则如何删除以前版本的安装程序:

enter image description here

enter image description here

我正在使用以下代码段,并使用该代码段弹出一个消息框,并在存在以前版本的情况下静默卸载。

ReadRegStr $R0 HKLM "SOFTWARE\EMR\Medical Record\3.01.00" "InstallPath"
${If} $R0 != ""
MessageBox MB_OKCANCEL "EMR is already installed in $R0 Remove the pervious version?" IDOK uninst
Abort
uninst:
ExecWait '"MsiExec.exe" /X{8ED262EE-FC73-47A9-BB86-D92223246881} /qn'   
${EndIf}

但是如何显示屏幕以向用户提供“更改,修复和删除”选项?

以下是我使用的更新代码,可以使用“删除”选项来卸载当前版本。请帮助我更改和修复选项的方法

Page custom nsDialogsPage nsDialogsPageLeave
  !insertmacro MUI_PAGE_INSTFILES

Function nsDialogsPage
nsDialogs::Create 1044
    Pop $Dialog
    ${If} $Dialog == error
        Abort
    ${EndIf}
!define MUI_REMOVEPAGE_TITLE_HEIGHT 30
${NSD_CreateLabel} 120u 10u 195u ${MUI_REMOVEPAGE_TITLE_HEIGHT}u "Remove Installation"
    Pop $RemovePageTitle
    CreateFont $RemovePageFont "$(^Font)" "12" "700"
    SendMessage $RemovePageTitle ${WM_SETFONT} $RemovePageFont 0 

${NSD_CreateButton} 12% 20% 25% 10% "Change"
        Pop $buttonRepair

        ${NSD_CreateLabel} 18% 35% 100% 12u "Change independently selectable features"
    Pop $Label

        ${NSD_CreateButton} 12% 50% 25% 10% "Repair"
        Pop $buttonRepair
         ${NSD_CreateButton} 12% 80% 25% 10% "Remove"
        Pop $buttonUninstall
        EnableWindow $button 1 # start out disabled
        EnableWindow $button2 1
        ${NSD_OnClick} $buttonRepair ManageRepair
        ${NSD_OnClick} $buttonUninstall ManageUninstall
    nsDialogs::Show

FunctionEnd

Function ManageRepair
    MessageBox MB_OK "Repair"
FunctionEnd

Function ManageUninstall
    MessageBox MB_OK "Uninstallation"
    ExecWait "$INSTDIR\uninstall.exe"
FunctionEnd

Function nsDialogsPageLeave

    ${NSD_GetText} $Text $0
    MessageBox MB_OK "You typed:$\n$\n$0"

FunctionEnd

1 个答案:

答案 0 :(得分:0)

我真的不明白为什么您只是在执行(ExecShell时试图在NSIS中复制它。如果已经安装了产品,.MSI应该会给您一个类似的对话框。

看看msiexec documentation,我们发现:

  • /x进行卸载。
  • /f进行修复。
  • /i“安装或配置产品”。

基于NSIS的安装程序不支持这些操作,但是通常只需在现有安装的顶部重新安装即可进行修复。

相关问题