Archive: Detect Firefox running under vista & W7


Detect Firefox running under vista & W7
  hello,
I try to detect if firefox is running.
I use the plugins fct and findprocdll but they do not work under vista and seven.
And for example in the wiki, you must have the exact title of the firefox window if it does not work.

Any idea to detect correctly firefox ?


I found the solution with nsProcess plugin.


The processes-plugin will do same.
nsprocess was longer time ago recognized from Eset NOD as malware - so i changed.


Look this code


Name "Test Firefox" ; The name of the installation
OutFile "Test Firefox.exe"

Function .onInit
Processes::FindProcess "firefox"
MessageBox MB_ICONSTOP|MB_OK "$R0"
StrCmp $R0 1 firefox_is_running firefox_not_running
firefox_is_running:
MessageBox MB_YESNO|MB_ICONQUESTION| "Mozilla Firefox et en cours de fonctionnement.$\r$\nVoulez vous l'arrêter ?" IDNO quit
fct::fct /WTP 'Mozilla Firefox' /TIMEOUT 2000
call .onInit
firefox_not_running:
goto ContinueInstall
quit:
MessageBox MB_ICONSTOP|MB_OK "Mozilla Firefox est en cours de fonctionnement.$\r$\nVous devez le fermer avant de continuer"
quit
ContinueInstall:
FunctionEnd

Section "dummy"

SectionEnd

With the firefox process name the value is always 1 although firefox is not running.

Processes plug-in works fine under Vista 32-bit for me but I can't say for 64-bit and Windows 7.

Stu


This code does not running under xp.


The Script works here - but it needs some modification:


Name    "Test Firefox"       ; The name of the installation

OutFile "Test_Firefox.exe"

>Function .onInit
Processes
::FindProcess "firefox.exe"
MessageBox MB_ICONSTOP|MB_OK "$R0"
StrCmp $R0 1 firefox_is_running firefox_not_running
firefox_is_running:
MessageBox MB_YESNO|MB_ICONQUESTION| "Mozilla Firefox et en cours de fonctionnement.$\r$\nVoulez vous l'arrêter ?" IDNO quit
Processes::KillProcess "firefox.exe"
IntCmp $R0 0 firefox_is_running
call.onInit
firefox_not_running:
goto ContinueInstall
quit:
MessageBox MB_ICONSTOP|MB_OK "Mozilla Firefox est en cours de fonctionnement.$\r$\nVous devez le fermer avant de continuer"
quit
ContinueInstall:
Quit
FunctionEnd

Section "dummy"

>SectionEnd
>
1. dont mix process plugins - use ONLY ONE (fct sux)
2. be more specific with names -> "firefox.exe" instead "firefox" - last could kill all windows with the name in it
3. script need admin power - does not work as normal user
(otherwise it returns always "0")

Check the README for the processes plugin!

hi,
Brummelchen, have tested your code and the return value is always 1.
my tests are done under windows xp with an administrator account.
If firefox is running, the process is not killed by Processes::KillProcess "firefox.exe"
according to the wiki (http://nsis.sourceforge.net/Processes_plug-in), we should not put .exe in the name of the process, but even so this does not


This code use the KillProc plugin


onInit

loop:
StrCpy $0 "firefox.exe"
KillProc::FindProcesses
StrCmp$1 "-1" wooops

StrCmp$0 "0" completed

MessageBox MB_OK "You must close firefox before continue"
Goto loop

wooops:
MessageBox MB_OK "-> Error: Something went wrong :-("
Abort

completed:
MessageBox MB_OK "Firefox is not running, all clear :-)"
>FunctionEnd
>
Running under windows seven.
I'm check under Xp and Vista.