Archive: Determining if a process is running


Determining if a process is running
Hi there again!

I just tried to find out if some process are running but the only way I find was FindWindow.
That's pretty nice for 90% of the processes I've to check but at least 6 processes doesn't have any hidden window so I need a possibility to determine if a process is running ... maybe via its exe-name ... that would be great :rolleyes:

Does anyone of you got any idea how to do that?

PS: I do not want to kill the processes I just only need to know if they are running


The only way is creating a new plugin for this task, I can do that later when I got free time

cyas


I wrote a small C++ (and another C# too) app which takes the process name as command line parameter and do the check for me.

Now it works - thx


Would you care to share your app with others? I can host it on the Archive downloads page if you'd like.


Of course ... I'll attach the source to this post :rolleyes:

Maybe I get enough time to convert it to a NSIS plugin ... :weird:

The Archive contains another two archives with the c++ and the c# source.

Tell me if you got any other questions :D


Has this been converted to a plugin? I have a need to check processes and pause if they're running. Thanks - Eric


That exe can be ran with Exec/nsExec to use it (I assume)
It is possible to write exe's that act like plugins, but it is harder to get the return value (unless you use nsExec::ExecToStack).

-Stu


If run this way, wouldn't the exe file have to live on the machine you deploy on? I'm trying to avoid having more pre-requisites on our servers...


hi there!

yea you are right - I run this exe with nsExec and put the exe to my installer package - works fine


stonkers, just copy it to $PLUGINSDIR using the File command. That's what NSIS does when you use a plug-in. The plug-in don't exist on the user's machine until the installer copies them to $PLUGINSDIR.


just copy it to $PLUGINSDIR using the File command. That's what NSIS does when you use a plug-in. The plug-in don't exist on the user's machine until the installer copies them to $PLUGINSDIR.
Sorry, don't really understand! I copy the file to pluginsdir (SetOutPath "$PLUGINSDIR"; File "CheckProcess.exe")

And this command only works on installer but not uninstaller
(nsExec::ExecToStack "CheckProcess application" $PLUGINSDIR)

Anything missed?

Thank you!

Add InitPluginsDir before using the plus-ins folder.


Yes, the plug-ins directory is not the same for the installer and the uninstaller. If you want to use it in the uninstaller, you'd have to copy it to the uninstaller plug-in's directory. Simply copy it somewhere in the uninstaller's code, un.onInit for example (don't forget to call InitPluginsDir before you use $PLUGINSDIR).