My electron application uses electron-builder to make NSIS for which i have created a custom install and uninstall script. Now when installing the application, i install and start some services and while uninstalling i stop and remove those. So for installation post uninstallation is working fine for me.
I recently implemented application update, and since uninstallation doesn’t occur, the installer tries to overwrite the present application file which works for the most part but not for services, i’ve tried adding the script in my custom installation to beginning of installation so that it mimics uninstallation. but i still get the same error on the NSIS installer i.e. :
Application_Name cannot be closed. Please close it manually and click
retry to continue.
this is popup on click of retry doesn’t work and on click of cancel, prompts another popup
i.e. :
Failed to uninstall old application files. Please try running the
installer again.
This is my customInstallationScript.nsh:
!macro customHeader
RequestExecutionLevel admin
!macroend
!macro customInstall
ExecWait 'taskkill /f /im * service1.exe'
Sleep 1000 ; 1 second delay
ExecWait 'sc.exe delete service1'
Sleep 1000 ; 1 second delay
ExecWait 'taskkill /f /im * service2.exe'
Sleep 1000 ; 1 second delay
ExecWait 'sc.exe delete service2'
Sleep 1000 ; 1 second delay
ExecWait 'taskkill /f /im * service3.exe'
Sleep 1000 ; 1 second delay
ExecWait 'sc.exe delete service3'
Sleep 1000 ; 1 second delay
ExecWait '"$INSTDIRpathtoservice1.exe" --install'
ExecWait 'sc.exe start service1'
Sleep 1000 ; 1 second delay
ExecWait '"$INSTDIRpathtoservice2.exe" --install'
ExecWait 'sc.exe start service2'
Sleep 1000 ; 1 second delay
ExecWait '"$INSTDIRpathtoservice3.exe" --install'
ExecWait 'sc.exe start service3'
!macroend
!macro customUnInstall
ExecWait 'sc.exe delete service1'
ExecWait 'taskkill /F /IM service1.exe'
Sleep 1000 ; 1 second delay
ExecWait 'sc.exe delete service2'
ExecWait 'taskkill /F /IM service2.exe'
Sleep 1000 ; 1 second delay
ExecWait 'sc.exe delete service3'
ExecWait 'taskkill /F /IM service3.exe'
!macroend