Search code examples
processnsis

NSIS detection of a 32-bit process in Win 7 x64


I have a rather common task for my NSIS installer - to find out if Firefox is running before the install, and ask the user to close it. But I haven't yet found a plugin that works for Windows 7 x64. I have tested Processes, FindProcDll, nsProcess - they all failed to detect the 32-bit firefox. I'd be grateful for any ideas where to look next.

Update: Actually, I couldn't detect the 64-bit firefox either with any of these plugins.


Solution

  • nsProcess works just fine for me. It also seems to be the most recently updated of the plug-ins you listed, so that's why I tested with that one. I'm using Win 7 x64 and confirmed in Task Manager that Firefox showed as "firefox.exe *32"

    !include nsProcess.nsh
    ...
    ${nsProcess::FindProcess} "firefox.exe" $R0
    ${If} $R0 == "0"
        # it's running
    ${EndIf}
    

    Possible return codes:

    0    Success
    603  Process was not currently running
    604  Unable to identify system type
    605  Unsupported OS
    606  Unable to load NTDLL.DLL
    607  Unable to get procedure address from NTDLL.DLL
    608  NtQuerySystemInformation failed
    609  Unable to load KERNEL32.DLL
    610  Unable to get procedure address from KERNEL32.DLL
    611  CreateToolhelp32Snapshot failed