|
|
Line 1: |
Line 1: |
| 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: [http://nsis.sourceforge.net/KillProc_plug-in]) to your nsis plug-ins folder'''
| |
|
| |
|
| |
| '''2) Paste the following macro in your script:'''
| |
| <highlight-nsis>
| |
| !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
| |
| </highlight-nsis>
| |
|
| |
| '''3) In the OnInit function of the installer add the following code:'''
| |
| <highlight-nsis>
| |
| ;Check if app is running
| |
| !insertmacro CheckAppRunning "MyApp.exe"
| |
| </highlight-nsis>
| |
|
| |
| '''4) Done!'''
| |
|
| |
| Cheers,
| |
| -Ross
| |
| 22:57, 6 January 2009 (UTC)
| |