Talk:Check whether your application is running: Difference between revisions
Ross.peralta (talk | contribs) No edit summary |
Revision as of 13:12, 30 June 2010
Hello...
First of all Thanks for the plug in. I want to check my application is running or not when user runs installer.The plug in worked for me
But today i found a strange bug in this plug in.. Suppose my executable name is MyApp.exe and when I use the plugin to find MyApp.exe is running or not. It was okay. But the problem if another application MyApp Daily.exe is running the the FindProcess API suceeds.
Thanks, Harikrishnan
I found the following to be much more useful for situations like this or if the title of your window is not static:
1) Add the KillProc.dll (found here: [1]) to your nsis plug-ins folder
2) Paste the following macro in your script:
!macro CheckAppRunning APP_PROCESS_NAME StrCpy $0 "${APP_PROCESS_NAME}" DetailPrint "Searching for processes called '$0'" KillProc::FindProcesses StrCmp $1 "-1" wooops Goto AppRunning AppRunning: DetailPrint "-> Found $0 processes running" StrCmp $0 "0" AppNotRunning MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "${APP_PROCESS_NAME} is currently running. $\n$\nDo you want to close it and continue installation?" IDYES KillApp DetailPrint "Installation Aborted!" Abort KillApp: StrCpy $0 "${APP_PROCESS_NAME}" DetailPrint "Killing all processes called '$0'" KillProc::KillProcesses StrCmp $1 "-1" wooops DetailPrint "-> Killed $0 processes, failed to kill $1 processes" sleep 1500 Goto AppNotRunning wooops: DetailPrint "-> Error: Something went wrong :-(" Abort AppNotRunning: DetailPrint "No Application Instances Found" !macroend
3) In the OnInit function of the installer add the following code:
;Check if app is running !insertmacro CheckAppRunning "MyApp.exe"
4) Done!
Cheers, -Ross 22:57, 6 January 2009 (UTC)