Skip to content

NSIS Uninstaller hangs if EnVar plugin and Banner are called #10

@sam-vdp

Description

@sam-vdp

I suspect this may be an issue with NSIS rather than EnVar, but I am not sure, so I am posting here for now.

When calling both EnVar and Banner from an unattended uninstaller, very often the uninstaller will hang after completing its work, with full CPU use on one thread. I cannot say exactly where the freeze occurs, but is after the un.onUninstSuccess handler is completed.

Minimal reproduction case (used NSIS version is 3.06.1, EnVar 0.3.1):

Unicode True

InstallDir $PROGRAMFILES64\Test

!include MUI2.nsh


OutFile "../out/test_installer.exe"

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

RequestExecutionLevel admin

Function .onInit
  SetRegView 64
FunctionEnd

Function un.PerformUninstall
  SetRegView 64
  
  SetAutoClose true

  ; Commenting either of the next two lines fixes the freeze
  Banner::destroy    
  EnVar::SetHKLM
  
  Delete "$INSTDIR\uninstall.exe"
  RMDir "$INSTDIR"
FunctionEnd

Section "Uninstall"
  Call un.PerformUninstall
SectionEnd

Function un.onUninstFailed
  MessageBox MB_OK "Uninstallation failed." /SD IDOK
FunctionEnd

Section 
  SetOverwrite On

  CreateDirectory "$INSTDIR"
  
  WriteUninstaller "$INSTDIR\uninstall.exe"
  
  EnVar::SetHKLM
SectionEnd

Can be tested with a batch script like this:

@echo off

:start
echo Installing...

start "" /WAIT test_installer.exe /S

echo.   Removing...
start "" /WAIT "C:\Program Files\Test\uninstall.exe" /S _?=C:\Program Files\Test

echo.
goto start

EDIT:
Appending /NOUNLOAD to the Banner::destroy fixes the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions