diff --git a/Installation/Windows/Templates/NSIS.template.in b/Installation/Windows/Templates/NSIS.template.in index 394c374916..fde3eba51a 100755 --- a/Installation/Windows/Templates/NSIS.template.in +++ b/Installation/Windows/Templates/NSIS.template.in @@ -579,6 +579,29 @@ FunctionEnd ;-------------------------------- +Function WaitForServiceDown + Push 0 + Pop $retryCount + try_again: + SimpleSC::ServiceIsRunning '${TRI_SVC_NAME}' + Pop $0 ; returns an errorcode (<>0) otherwise success (0) + Pop $1 ; returns 1 (service is running) - returns 0 (service is not running) + ${If} $1 == 0 + ;MessageBox MB_OK "Service running : $retryCount " + ; ok, running now. + Return + ${EndIf} + Sleep 1000 + ${If} $retryCount == 40 + MessageBox MB_OK "Service shutdown waiting retry count reached; you may need to remove files by hand" + Return + ${EndIf} + IntOp $retryCount $retryCount + 1 + Goto try_again +FunctionEnd + +;-------------------------------- + !ifdef CPACK_USES_DOWNLOAD Function DownloadFile IfFileExists $INSTDIR\* +2 @@ -818,6 +841,7 @@ Section "-Core installation" @CPACK_NSIS_EXTRA_INSTALL_COMMANDS@ StrCmp $TRI_INSTALL_TYPE 'Service' 0 nothing SimpleSC::StopService '${TRI_SVC_NAME}' 0 30 + Call WaitForServiceDown SimpleSC::RemoveService '${TRI_SVC_NAME}' SimpleSC::InstallService '${TRI_SVC_NAME}' '${TRI_SVC_NAME}' '16' '2' '"$INSTDIR\${SBIN_DIR}\arangod.exe" --start-service' '' '' '' SimpleSC::SetServiceDescription '${TRI_SVC_NAME}' '${TRI_FRIENDLY_SVC_NAME}' @@ -1187,6 +1211,7 @@ Section "Uninstall" StrCmp $1 '"$INSTDIR/${SBIN_DIR}/arangod.exe" --start-service' '' Done DetailPrint 'Shutting down Service' SimpleSC::StopService '${TRI_SVC_NAME}' 0 30 + Call WaitForServiceDown SimpleSC::RemoveService '${TRI_SVC_NAME}' Pop $0 ; returns an errorcode (<>0) otherwise success (0) IntCmp $0 0 Done +1 +1