Skip to content
⌘ NSIS Forum Archive

Determining if a process is running

13 posts

zwuba#

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 🙄

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
ramon18#
The only way is creating a new plugin for this task, I can do that later when I got free time

cyas
zwuba#
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
Sunjammer#
Would you care to share your app with others? I can host it on the Archive downloads page if you'd like.
zwuba#
Of course ... I'll attach the source to this post 🙄

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

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

Tell me if you got any other questions 😁
stonkers#
Has this been converted to a plugin? I have a need to check processes and pause if they're running. Thanks - Eric
Afrow UK#
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
stonkers#
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...
zwuba#
hi there!

yea you are right - I run this exe with nsExec and put the exe to my installer package - works fine
kichik#
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.
ursus76#
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!
kichik#
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).