check during uninstall for running applications

This commit is contained in:
Stephen Birarda 2016-01-18 15:50:44 -08:00
parent a83c3a3385
commit 4fb5a142f7
3 changed files with 33 additions and 1 deletions

View file

@ -54,6 +54,9 @@ macro(SET_PACKAGING_PARAMETERS)
set(CONSOLE_EXEC_NAME "server-console.exe")
set(DS_EXEC_NAME "domain-server.exe")
set(AC_EXEC_NAME "assignment-client.exe")
# start menu shortcuts
set(INTERFACE_SM_SHORTCUT_NAME "High Fidelity")
set(CONSOLE_SM_SHORTCUT_NAME "Server Console")

View file

@ -13,6 +13,8 @@ set(INTERFACE_SHORTCUT_NAME "@INTERFACE_SM_SHORTCUT_NAME@")
set(INTERFACE_WIN_EXEC_NAME "@INTERFACE_EXEC_PREFIX@.exe")
set(CONSOLE_SHORTCUT_NAME "@CONSOLE_SM_SHORTCUT_NAME@")
set(CONSOLE_WIN_EXEC_NAME "@CONSOLE_EXEC_NAME@")
set(DS_EXEC_NAME "@DS_EXEC_NAME@")
set(AC_EXEC_NAME "@AC_EXEC_NAME@")
set(HIGH_FIDELITY_PROTOCOL "@HIGH_FIDELITY_PROTOCOL@")
set(PRODUCTION_BUILD "@PRODUCTION_BUILD@")
set(POST_INSTALL_OPTIONS_PATH "@POST_INSTALL_OPTIONS_PATH@")

View file

@ -984,7 +984,31 @@ Function HandlePostInstallOptions
FunctionEnd
!include WinVer.nsh
!define FindProc_NOT_FOUND 1
!define FindProc_FOUND 0
!macro FindProc result processName
ExecCmd::exec "%SystemRoot%\System32\tasklist /NH /FI $\"IMAGENAME eq ${processName}$\" | %SystemRoot%\System32\find /I $\"${processName}$\""
Pop $0 ; The handle for the process
ExecCmd::wait $0
Pop ${result} ; The exit code
!macroend
Var processFound
!macro PromptForRunningApplication applicationName displayName
!insertmacro FindProc $processFound ${applicationName}
${If} $processFound == FindProc_FOUND
MessageBox MB_OK|MB_ICONEXCLAMATION "The High Fidelity ${displayName} is running. Please close it first." /SD IDOK
${EndIf}
!macroend
!macro CheckForRunningApplications
!insertmacro PromptForRunningApplication "@INTERFACE_WIN_EXEC_NAME@" "Client"
!insertmacro PromptForRunningApplication "@CONSOLE_WIN_EXEC_NAME@" "Server Console"
!insertmacro PromptForRunningApplication "@DS_EXEC_NAME@" "domain-server"
!insertmacro PromptForRunningApplication "@AC_EXEC_NAME@" "assignment-client"
!macroend
;--------------------------------
; determine admin versus local install
@ -1001,6 +1025,9 @@ Function un.onInit
Quit
${EndIf}
; make sure none of the installed applications are still running
!insertmacro CheckForRunningApplications
; attempt to elevate the uninstaller to admin status
uac_tryagain:
!insertmacro UAC_RunElevated