Search code examples
nsis

When installing the same version of the windows installer software second time instead of silently installing it is showing the error message


I installed the windows installer software first time and it was installed properly. If I manually uninstall the software from control panel->Add/Remove Programs then it is installing without showing any error message.

In the Section "Uninstall", I wrote the below code

Section "Uninstall"

  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Test"
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Test\EMR"
  DeleteRegKey HKLM "SOFTWARE\Test\EMR"
  DeleteRegKey HKLM "SOFTWARE\Test"

  ; Remove files and uninstaller
  Delete $INSTDIR\EMR_4.0.1.nsi
  Delete $INSTDIR\uninstall.exe

  ; Remove shortcuts, if any
  Delete "$INSTDIR\Test\EMR\*.*"

  ; Remove directories used
  RMDir "$INSTDIR\Test\EMR"
  RMDir "$INSTDIR\Test"
  RMDir "$INSTDIR"

 RMDir /r /REBOOTOK $INSTDIR
SectionEnd

Please help me to resolve the error.


Solution

  • It is hard to tell what is really going on based on your description but it is most likely one of two things:

    • The file is in use (open in another program or the program/service itself is running).

    or

    • You don't have write access to that file. Make sure the installer is UAC elevated by setting the RequestExecutionLevel attribute.