Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 16th July 2007, 22:11   #1
bobics
Junior Member
 
Join Date: May 2006
Location: San Francisco, CA
Posts: 25
how to detect (and kill) if a process is running for *all* users?

I'm using FindProcDLL to detect if a process is running, but it appears it only detects it for the currently logged in user. In some cases this might be okay, but our app may be running with multiple users logged in (i.e. with Fast User Switching in XP).

At the minimum we'd like to detect if our app is running from another user's account. We may also want to kill the other user's process (which I assume should be pretty straightforward once I have the handle).

TIA,
bobics
bobics is offline   Reply With Quote
Old 17th July 2007, 16:46   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Have you tried one of the other process detection plug-ins?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 17th July 2007, 19:57   #3
bobics
Junior Member
 
Join Date: May 2006
Location: San Francisco, CA
Posts: 25
It took me some time but here are the results.

Of the plugins/sample scripts I tried, only nsProcess::FindProcess detected another user's process (and I think I picked one implementation out of every bucket). In case it might be helpful to anyone else, here's my sample script:

code:

SetCompressor /solid lzma

!include "nsProcess.nsh"
!include "FindProcess.nsh"

;--- Project Settings --------
OutFile "setup.exe"

Section
SectionEnd

Function .onInit
FindProcDLL::FindProc "firefox.exe"
MessageBox MB_OK "FindProcDLL::FindProc = $R0 (found=1)"

${nsProcess::FindProcess} "firefox.exe" $0
MessageBox MB_OK "nsProcess::FindProcess = $0 (found=0)"

Processes::FindProcess "firefox.exe"
MessageBox MB_OK "Processes::FindProcess = $R0 (found=1)"
;Call listProcesses

FindWindow $0 "MozillaUIWindowClass" ""
MessageBox MB_OK "FindWindow = $0 (found<>0)"

${FindProcess} "firefox.exe" $0
MessageBox MB_OK "FindProcess = $0 (found=1)"

;I think there's a bug in fct, it just kills the process
fct::fct /MSGONLY /QUESTION "Terminate?" /WC "MozillaUIWindowClass" /WTP "Firefox"

abort
FunctionEnd

bobics is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump