Xarkam
17th June 2009 08:40 UTC
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 ?
Xarkam
17th June 2009 09:29 UTC
I found the solution with nsProcess plugin.
Brummelchen
23rd June 2009 19:33 UTC
The processes-plugin will do same.
nsprocess was longer time ago recognized from Eset NOD as malware - so i changed.
Xarkam
24th June 2009 09:46 UTC
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.
Afrow UK
24th June 2009 12:23 UTC
Processes plug-in works fine under Vista 32-bit for me but I can't say for 64-bit and Windows 7.
Stu
Xarkam
24th June 2009 16:18 UTC
This code does not running under xp.
Brummelchen
27th June 2009 22:51 UTC
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!
Xarkam
3rd July 2009 09:12 UTC
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
Xarkam
7th July 2009 19:31 UTC
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.