Announcement

Collapse
No announcement yet.

how to detect (and kill) if a process is running for *all* users?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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

    Comment


    • #3
      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

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎