Link process to another process (for auto-close)

Started by Autumner, March 09, 2015, 09:47:47 AM

Previous topic - Next topic

Autumner

Hello everyone, here's what I'm trying to do. There's an application (A) that when opened, it also opens another background .exe process (B). When A is closed though, B (which is not required by anything else) remains open. Is there a way to set B to always close when A is closed/not present? I thought of the "disallowed processes" option window but not sure how the Exceptions [allowed] column works.

Thanks!

arcanum

Hi,

I think that its a main process that runs a "how the coders says it" parent/child process that when exit, it cannot close its parent process. Which is a sign of "bad" coding. Simple api call CLOSE(process name) should close the proggie and its parent processes. Dunno how to do it via Process Lasso. One way might be by using taskill /PID /T and make it a .bat. However, the PID is not the same during every boot, so taskill /T processname should work?

-arc




Autumner

Thanks. You mean there's a way for Lasso to execute a .bat file when a process is closed?

BenYeeHua

Yup, watchdog, you can found it on Options- Configure process watchdog. ;)
Just too bad it don't has the function to kill other process, but it has feature to launch other processes. :P

It should be cmd.exe for the processes that you need to be launched, then just set the command line. :)

Autumner

Thanks! Tried BenYeeHua's method first but probably incorrectly. B has constant and very low cpu/memory usage (independent of what A is doing) so I created a watchdog rule for A. Virtual memory less than 1M for 5 seconds, then execute cmd.exe with command line: taskkill /f /im B.exe. Couldn't think of another way to link it to B. This probably won't work though, since when A is closed it's no longer monitored. Also, every time I open A a cmd.exe window pops-up (can't figure out why, A uses at least 30M of memory).

BenYeeHua

QuoteAlso, every time I open A a cmd.exe window pops-up (can't figure out why, A uses at least 30M of memory).
So it did using at least more than 1M for 5 seconds after you just run the A.exe? :)

If it has more than 1M, then maybe it is a bug, you can open a thread at BugTrack to report this bug. ;)
---
Hmm...
You can also just create a bat that run a hidden CMD, then launch A.exe, wait until A.exe is closed, then kill B.exe.

But ya, you may request a new feature for WatchDog, but ya, it can adding more feature, just the resource is the problem to do that... :P

edkiefer

That seems like a worthy feature, close all child process if parent closes .
I have seen a few app leave child's run free ;)
Bitsum QA Engineer

Autumner

Quote from: BenYeeHua on March 10, 2015, 04:48:14 PM
So it did using at least more than 1M for 5 seconds after you just run the A.exe? :) If it has more than 1M, then maybe it is a bug, you can open a thread at BugTrack to report this bug. ;)  --- Hmm...
You can also just create a bat that run a hidden CMD, then launch A.exe, wait until A.exe is closed, then kill B.exe.
But ya, you may request a new feature for WatchDog, but ya, it can adding more feature, just the resource is the problem to do that... :P

The cmd.exe opens immediately, together with A. Maybe a bug but I'll have to test a bit more. The hidden CMD seems a bit too complicated, I'll probably add a feature request.

Quote from: edkiefer on March 10, 2015, 06:30:33 PM
That seems like a worthy feature, close all child process if parent closes. I have seen a few app leave child's run free ;)

I am not sure if these are child/parent processes and I don't really know how to verify that. Is there a way?

BenYeeHua

QuoteThe hidden CMD seems a bit too complicated, I'll probably add a feature request.
Ya, you need to run vbs for running a hidden cmd, by using the code below :P

Set oShell = CreateObject ("Wscript.Shell")
Dim strArgs
strArgs = "cmd /c xx.bat"
oShell.Run strArgs, 0, false

Jeremy Collake

Quote from: arcanum on March 10, 2015, 04:53:06 AM
I think that its a main process that runs a "how the coders says it" parent/child process that when exit, it cannot close its parent process. Which is a sign of "bad" coding. Simple api call CLOSE(process name) should close the proggie and its parent processes. Dunno how to do it via Process Lasso. One way might be by using taskill /PID /T and make it a .bat. However, the PID is not the same during every boot, so taskill /T processname should work?
-arc

That is an interesting feature, but your implication that not doing so already is 'bad' and, thus, insulting. In fact, the opposite is true.

By your logic, closing a program launched at startup by the Task Scheduler would close the Task Scheduler as well.

The Windows API 'TerminateProcess' acts just as it should - it terminates that specific process and no others.
Software Engineer. Bitsum LLC.

Jeremy Collake

And BenYeeHua's advice is for people knowledgeable enough to do basic scripting. DO NOT ATTEMPT unless you can deduce what his commands mean.
Software Engineer. Bitsum LLC.

Jeremy Collake

Quote from: arcanum on March 10, 2015, 04:53:06 AM
I think that its a main process that runs a "how the coders says it" parent/child process that when exit, it cannot close its parent process. Which is a sign of "bad" coding. Simple api call CLOSE(process name) should close the proggie and its parent processes. Dunno how to do it via Process Lasso. One way might be by using taskill /PID /T and make it a .bat. However, the PID is not the same during every boot, so taskill /T processname should work?

Dunno what 'Close' command you are using, but no scenario I can think of, including the APIs to Terminate processes, that would also terminate the parent process(es). You might end up terminating explorer, for instance, if the user ran the process via WIN+R. And how far up the chain to go? First parent? Second parent? Third parent? Makes no sense.
Software Engineer. Bitsum LLC.