Bitsum Community Forum

General Category => Process Lasso => Topic started by: Autumner on March 09, 2015, 09:47:47 AM

Title: Link process to another process (for auto-close)
Post by: Autumner on March 09, 2015, 09:47:47 AM
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!
Title: Re: Link process to another process (for auto-close)
Post by: arcanum on March 10, 2015, 04:53:06 AM
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



Title: Re: Link process to another process (for auto-close)
Post by: Autumner on March 10, 2015, 11:46:25 AM
Thanks. You mean there's a way for Lasso to execute a .bat file when a process is closed?
Title: Re: Link process to another process (for auto-close)
Post by: BenYeeHua on March 10, 2015, 12:20:01 PM
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. :)
Title: Re: Link process to another process (for auto-close)
Post by: Autumner on March 10, 2015, 12:47:20 PM
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).
Title: Re: Link process to another process (for auto-close)
Post by: BenYeeHua on March 10, 2015, 04:48:14 PM
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 (https://bitsum.com/forum/index.php?board=39.0) 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
Title: Re: Link process to another process (for auto-close)
Post by: 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 ;)
Title: Re: Link process to another process (for auto-close)
Post by: Autumner on March 10, 2015, 09:48:08 PM
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 (https://bitsum.com/forum/index.php?board=39.0) 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?
Title: Re: Link process to another process (for auto-close)
Post by: BenYeeHua on March 11, 2015, 06:47:12 AM
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
Title: Re: Link process to another process (for auto-close)
Post by: Jeremy Collake on March 11, 2015, 02:46:32 PM
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.
Title: Re: Link process to another process (for auto-close)
Post by: Jeremy Collake on March 11, 2015, 02:49:02 PM
And BenYeeHua's advice is for people knowledgeable enough to do basic scripting. DO NOT ATTEMPT unless you can deduce what his commands mean.
Title: Re: Link process to another process (for auto-close)
Post by: Jeremy Collake on March 11, 2015, 02:54:24 PM
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.