Xojo Conferences
XDCMay2019MiamiUSA

[MBS] Getting "childs" processes (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] API for scanner
Next thread: [MBS] [ANN] 17.3pr3


Re: [MBS] 9.3pr11   -   Garth Hjelte
  [MBS] Getting "childs" processes   -   Jean-Luc Arnaud
   Re: [MBS] Getting "childs" processes   -   Marnaud
   Re: [MBS] Getting "childs" processes   -   Jean-Luc Arnaud
    Re: [MBS] Getting "childs" processes   -   Jean-Luc Arnaud

[MBS] Getting "childs" processes
Date: 28.06.17 11:51 (Wed, 28 Jun 2017 12:51:31 +0200)
From: Jean-Luc Arnaud
Hi all MBS users,

I'm using ProcessMBS class in order to kill some processes.

Usually, when a process is killed, the processes it may have launched
are killed, too.

Unfortunately, this does not work with Robocopy (files copy utility from
Microsoft).

Launched by a slave app, when I kill the process of this app, Robocopy
continues copying all the files/folders it has to copy.

So, I need to kill Robocopy, too. But I have several slave apps and, of
course, several Robocopy processes.

How to know what Robocopy process has been launched by a certain slave
app? Kind of "child process" of a process.

Is there a way, using MBS or any other resource (i.e. dll call)?

TIA for any help.

Re: [MBS] Getting "childs" processes
Date: 29.06.17 17:31 (Thu, 29 Jun 2017 18:31:10 +0200)
From: Marnaud
Le 28 juin 2017 à 12:51 du soir, Jean-Luc Arnaud <<email address removed>> a écrit:

> Hi all MBS users,
>
> I'm using ProcessMBS class in order to kill some processes.
>
> Usually, when a process is killed, the processes it may have launched
> are killed, too.
>
> Unfortunately, this does not work with Robocopy (files copy utility from
> Microsoft).
>
> Launched by a slave app, when I kill the process of this app, Robocopy
> continues copying all the files/folders it has to copy.
>
> So, I need to kill Robocopy, too. But I have several slave apps and, of
> course, several Robocopy processes.
>
> How to know what Robocopy process has been launched by a certain slave
> app? Kind of "child process" of a process.
>
> Is there a way, using MBS or any other resource (i.e. dll call)?

Hello Jean-Luc,

I know it’s too late for you, because you found another approach, but, just for the archives, I’ve found that you can use this shell command to get process id of child processes:
wmic process where (ParentProcessId=0) get Caption,ProcessId

Replace 0 by the actual process id of the parent process.
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Getting "childs" processes
Date: 29.06.17 11:44 (Thu, 29 Jun 2017 12:44:19 +0200)
From: Jean-Luc Arnaud
No reply?

Searching on Internet, I found this code for .Net:

// Function killing a process and its children, passing its pid
Public Sub KillProcessAndChildren(ByVal pidAs Integer)
Dim mAs New Management.ManagementObjectSearcher("select ProcessId from Win32_Process where
ParentProcessId=" & pid)
Dim cAs Management.ManagementObjectCollection = m.Get()
For Each itmAs Management.ManagementBaseObject In c
KillProcessAndChildren(Convert.ToInt32(itm("ProcessId")))
Next
Process.GetProcessById(pid).Kill()
End Sub It seems like a WMI call (3rd line). Who could help me translate
this into Xojo code? Thanks a lot.

Jean-Luc Arnaud

Le 28/06/2017 à 12:51, Jean-Luc Arnaud a écrit :
> Hi all MBS users,
>
> I'm using ProcessMBS class in order to kill some processes.
>
> Usually, when a process is killed, the processes it may have launched
> are killed, too.
>
> Unfortunately, this does not work with Robocopy (files copy utility from
> Microsoft).
>
> Launched by a slave app, when I kill the process of this app, Robocopy
> continues copying all the files/folders it has to copy.
>
> So, I need to kill Robocopy, too. But I have several slave apps and, of
> course, several Robocopy processes.
>
> How to know what Robocopy process has been launched by a certain slave
> app? Kind of "child process" of a process.
>
> Is there a way, using MBS or any other resource (i.e. dll call)?
>
> TIA for any help.
>

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Getting "childs" processes
Date: 29.06.17 14:47 (Thu, 29 Jun 2017 15:47:48 +0200)
From: Jean-Luc Arnaud
Ok, I solved the problem by myself, using the shell command TaskKill and
options /F /T.

Christian, could you please add these options in your ProcessMBS class,
function KillProcess?

Thanks a lot.

Jean-Luc Arnaud

Le 29/06/2017 à 12:44, Jean-Luc Arnaud a écrit :
> No reply?
>
> Searching on Internet, I found this code for .Net:
>
> // Function killing a process and its children, passing its pid
> Public Sub KillProcessAndChildren(ByVal pidAs Integer)
> Dim mAs New Management.ManagementObjectSearcher("select ProcessId from Win32_Process where
> ParentProcessId=" & pid)
> Dim cAs Management.ManagementObjectCollection = m.Get()
> For Each itmAs Management.ManagementBaseObject In c
> KillProcessAndChildren(Convert.ToInt32(itm("ProcessId")))
> Next
> Process.GetProcessById(pid).Kill()
> End Sub It seems like a WMI call (3rd line). Who could help me translate
> this into Xojo code? Thanks a lot.
>
> Jean-Luc Arnaud
>
> Le 28/06/2017 à 12:51, Jean-Luc Arnaud a écrit :
>> Hi all MBS users,
>>
>> I'm using ProcessMBS class in order to kill some processes.
>>
>> Usually, when a process is killed, the processes it may have launched
>> are killed, too.
>>
>> Unfortunately, this does not work with Robocopy (files copy utility from
>> Microsoft).
>>
>> Launched by a slave app, when I kill the process of this app, Robocopy
>> continues copying all the files/folders it has to copy.
>>
>> So, I need to kill Robocopy, too. But I have several slave apps and, of
>> course, several Robocopy processes.
>>
>> How to know what Robocopy process has been launched by a certain slave
>> app? Kind of "child process" of a process.
>>
>> Is there a way, using MBS or any other resource (i.e. dll call)?
>>
>> TIA for any help.
>>
> _______________________________________________
> Mbsplugins_monkeybreadsoftware.info mailing list
> <email address removed>
> https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info