Check whether your application is running: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Added category links.)
m (Removed Modern UI dependence. Fixed some spelling.)
Line 3: Line 3:
|}
|}
<br style="clear:both;">
<br style="clear:both;">
== The Script ==
 
== Description ==
This example detects if the application you are uninstalling is running at the start of the uninstallation process.
 
== The Example Script ==
<highlight-nsis>
<highlight-nsis>
;If application is running during uninstallation,exe file is not removed !!
/* Replace the values of the two defines below to your application's window class and window title, respectivelly. */
;This code checks for an instance of application and Prompts the user to close ;application before resuming uninstallation ..
!define WNDCLASS "WindowClassOfYourApplication"
!define WNDTITLE "WindowTitleOfYourApplication"


Function un.onInit
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
   FindWindow $0 "${WNDCLASS}" "${WNDTITLE}"
   FindWindow $0 "WindowClassOfYourApplication" "WindowTitleOfYourApplication"
   StrCmp $0 0 0 continueInstall
   StrCmp $0 "00 +3     ;if window active goto +3
     MessageBox MB_ICONSTOP|MB_OK "The application you are trying to remove is running. Close it and try again."
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +4 
    Abort
  Abort
   continueInstall:
  MessageBox MB_ICONEXCLAMATION|MB_OK "Installer Found that Application you are trying to remove is running.Close it and try again!!"
   Abort
FunctionEnd
FunctionEnd
</highlight-nsis>


;For any queries mail me at :saabz_500@yahoo.co.uk
For any queries mail me at :saabz_500@yahoo.co.uk
</highlight-nsis>


[[{{ns:14}}:Code Examples]]
[[{{ns:14}}:Code Examples]]

Revision as of 23:36, 21 June 2005

Author: saabz_500 (talk, contrib)


Description

This example detects if the application you are uninstalling is running at the start of the uninstallation process.

The Example Script

/* Replace the values of the two defines below to your application's window class and window title, respectivelly. */
!define WNDCLASS "WindowClassOfYourApplication"
!define WNDTITLE "WindowTitleOfYourApplication"
 
Function un.onInit
  FindWindow $0 "${WNDCLASS}" "${WNDTITLE}"
  StrCmp $0 0 0 continueInstall
    MessageBox MB_ICONSTOP|MB_OK "The application you are trying to remove is running. Close it and try again."
    Abort
  continueInstall:
FunctionEnd

For any queries mail me at :saabz_500@yahoo.co.uk