Discussion:
Shell, tasks and taskkill
Jean-Luc Arnaud
2016-10-26 09:09:13 UTC
Permalink
Hi all,

Using a shell and Robocopy; I manage some files duplication.
I have 2 questions:

- Is there a way, when executing the command launching the files
duplication with Robocopy (MyShell.execute ....), to get back the PID of
the instance of Robocopy, given that it may have several instances of
Robocopy running at a time? Of course, I could list all of PIDs before
and after the shell command, but is there somzthing easier and faster?

- When needed, I kill (using Taskkill /F /T) one of the Robocopy
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?

TIA for any advice/help.
--
Jean-Luc Arnaud


_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Jean-Luc Arnaud
2016-11-10 09:25:19 UTC
Permalink
Never got a reply to this question (yes, i'm a poor lonesome guy :'().

Any idea?

TIA

Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
Using a shell and Robocopy; I manage some files duplication.
- Is there a way, when executing the command launching the files
duplication with Robocopy (MyShell.execute ....), to get back the PID
of the instance of Robocopy, given that it may have several instances
of Robocopy running at a time? Of course, I could list all of PIDs
before and after the shell command, but is there somzthing easier and
faster?
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA for any advice/help.
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <listhelp@
Bernd Fröhlich
2016-11-10 09:40:27 UTC
Permalink
when you append
& export PID=$!
to your call that starts robocopy, you get the process id in the shellvariable PID.
Then you can later call
kill $PID
to kill it.

Greetings from Germany,
Bernd Fröhlich
Post by Jean-Luc Arnaud
Never got a reply to this question (yes, i'm a poor lonesome guy :'().
Any idea?
TIA
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
Using a shell and Robocopy; I manage some files duplication.
- Is there a way, when executing the command launching the files
duplication with Robocopy (MyShell.execute ....), to get back the PID
of the instance of Robocopy, given that it may have several instances
of Robocopy running at a time? Of course, I could list all of PIDs
before and after the shell command, but is there somzthing easier and
faster?
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA for any advice/help.
_______________________________________________
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Jean-Luc Arnaud
2016-11-10 10:25:44 UTC
Permalink
Great!

I didn't know this possibility (of course, else I wouldn't have asked
the question ... !)

Thanks a lot, Bernd.

Jean-Luc Arnaud
Post by Bernd Fröhlich
when you append
& export PID=$!
to your call that starts robocopy, you get the process id in the shellvariable PID.
Then you can later call
kill $PID
to kill it.
Greetings from Germany,
Bernd Fröhlich
Post by Jean-Luc Arnaud
Never got a reply to this question (yes, i'm a poor lonesome guy :'().
Any idea?
TIA
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
Using a shell and Robocopy; I manage some files duplication.
- Is there a way, when executing the command launching the files
duplication with Robocopy (MyShell.execute ....), to get back the PID
of the instance of Robocopy, given that it may have several instances
of Robocopy running at a time? Of course, I could list all of PIDs
before and after the shell command, but is there somzthing easier and
faster?
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA for any advice/help.
_______________________________________________
_______________________________________________
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Jean-Luc Arnaud
2016-11-10 10:39:51 UTC
Permalink
Unfortunately, export is a Linux command, Windows shell doesn't
recognize it. Too bad!

Nevertheless, your reply helped me searching and mainly finding the
solution on the Web:

wmic process call create "ProcessToLaunch.exe" | find "ProcessId"

launches the process and returns its PID.

Thanks again.

Jean-Luc Arnaud
Post by Bernd Fröhlich
when you append
& export PID=$!
to your call that starts robocopy, you get the process id in the shellvariable PID.
Then you can later call
kill $PID
to kill it.
Greetings from Germany,
Bernd Fröhlich
Post by Jean-Luc Arnaud
Never got a reply to this question (yes, i'm a poor lonesome guy :'().
Any idea?
TIA
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
Using a shell and Robocopy; I manage some files duplication.
- Is there a way, when executing the command launching the files
duplication with Robocopy (MyShell.execute ....), to get back the PID
of the instance of Robocopy, given that it may have several instances
of Robocopy running at a time? Of course, I could list all of PIDs
before and after the shell command, but is there somzthing easier and
faster?
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA for any advice/help.
_______________________________________________
_______________________________________________
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Bernd Fröhlich
2016-11-10 10:48:36 UTC
Permalink
Post by Jean-Luc Arnaud
Unfortunately, export is a Linux command, Windows shell doesn't
recognize it. Too bad!
Nevertheless, your reply helped me searching and mainly finding the
wmic process call create "ProcessToLaunch.exe" | find "ProcessId"
launches the process and returns its PID.
Thanks again.
I had that problem recently when I was writing a small shellscript on Mac OS (not Xojo related).
The "& export PID=$!" solution worked fine for me.
Good to know that you found a solution for Windows as well.

Greetings from Germany,
Bernd Fröhlich


_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Jean-Luc Arnaud
2016-11-10 14:12:11 UTC
Permalink
Post by Bernd Fröhlich
The "& export PID=$!" solution worked fine for me.
You're right, export is not only a Linux, but also a UNIX command, and
works on Mac OS.

Good to know...

Kind regards,

Jean-Luc Arnaud
Post by Bernd Fröhlich
Post by Jean-Luc Arnaud
Unfortunately, export is a Linux command, Windows shell doesn't
recognize it. Too bad!
Nevertheless, your reply helped me searching and mainly finding the
wmic process call create "ProcessToLaunch.exe" | find "ProcessId"
launches the process and returns its PID.
Thanks again.
I had that problem recently when I was writing a small shellscript on Mac OS (not Xojo related).
The "& export PID=$!" solution worked fine for me.
Good to know that you found a solution for Windows as well.
Greetings from Germany,
Bernd Fröhlich
_______________________________________________
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Jean-Luc Arnaud
2016-11-10 15:34:51 UTC
Permalink
Thanks to Bernd for replying to the first par of the question.

What about the second part?
Post by Jean-Luc Arnaud
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA

Jean-Luc Arnaud
Post by Jean-Luc Arnaud
when you append
& export PID=$!
to your call that starts robocopy, you get the process id in the shellvariable PID.
Then you can later call
kill $PID
to kill it.
Greetings from Germany,
Bernd Fröhlich
Post by Jean-Luc Arnaud
Never got a reply to this question (yes, i'm a poor lonesome guy :'().
Any idea?
TIA
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
Using a shell and Robocopy; I manage some files duplication.
- Is there a way, when executing the command launching the files
duplication with Robocopy (MyShell.execute ....), to get back the PID
of the instance of Robocopy, given that it may have several instances
of Robocopy running at a time? Of course, I could list all of PIDs
before and after the shell command, but is there somzthing easier and
faster?
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA for any advice/help.
_______________________________________________
_______________________________________________
_______________________________________________
Unsubscribe by sending a message to:
<nug-***@lists.xojo.com>

List Help: <***@xojo.com>
Bob Coleman
2016-11-10 15:42:21 UTC
Permalink
I googled wmi process kill and a load of suggestions.

https://msdn.microsoft.com/en-us/library/aa393907(v=vs.85).aspx

https://blogs.technet.microsoft.com/heyscriptingguy/2011/08/08/learn-four-ways-to-kill-a-process-using-powershell-and-wmi/

I haven't tried either but they might help.

-Bob
Post by Jean-Luc Arnaud
Thanks to Bernd for replying to the first par of the question.
What about the second part?
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
Post by Jean-Luc Arnaud
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA
Jean-Luc Arnaud
when you append
Post by Jean-Luc Arnaud
& export PID=$!
to your call that starts robocopy, you get the process id in the shellvariable PID.
Then you can later call
kill $PID
to kill it.
Greetings from Germany,
Bernd Fröhlich
Never got a reply to this question (yes, i'm a poor lonesome guy :'().
Post by Jean-Luc Arnaud
Any idea?
TIA
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
Using a shell and Robocopy; I manage some files duplication.
- Is there a way, when executing the command launching the files
duplication with Robocopy (MyShell.execute ....), to get back the PID
of the instance of Robocopy, given that it may have several instances
of Robocopy running at a time? Of course, I could list all of PIDs
before and after the shell command, but is there somzthing easier and
faster?
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA for any advice/help.
_______________________________________________
_______________________________________________
_______________________________________________
_______________________________________________
Unsubscribe by sending a message to:
<nug-leave@
Jean-Luc Arnaud
2016-11-15 09:03:45 UTC
Permalink
Very interesting, Bob.

Thanks a lot.

Jean-Luc Arnaud
Post by Bob Coleman
I googled wmi process kill and a load of suggestions.
https://msdn.microsoft.com/en-us/library/aa393907(v=vs.85).aspx
https://blogs.technet.microsoft.com/heyscriptingguy/2011/08/08/learn-four-ways-to-kill-a-process-using-powershell-and-wmi/
I haven't tried either but they might help.
-Bob
Post by Jean-Luc Arnaud
Thanks to Bernd for replying to the first par of the question.
What about the second part?
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
Post by Jean-Luc Arnaud
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA
Jean-Luc Arnaud
when you append
Post by Jean-Luc Arnaud
& export PID=$!
to your call that starts robocopy, you get the process id in the shellvariable PID.
Then you can later call
kill $PID
to kill it.
Greetings from Germany,
Bernd Fröhlich
Never got a reply to this question (yes, i'm a poor lonesome guy :'().
Post by Jean-Luc Arnaud
Any idea?
TIA
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
Using a shell and Robocopy; I manage some files duplication.
- Is there a way, when executing the command launching the files
duplication with Robocopy (MyShell.execute ....), to get back the PID
of the instance of Robocopy, given that it may have several instances
of Robocopy running at a time? Of course, I could list all of PIDs
before and after the shell command, but is there somzthing easier and
faster?
- When needed, I kill (using Taskkill /F /T) one of the Robocopy
instance as a result of User cancellation. Nevertheless, Robocopy does
not stop immediately, it finishes to copy the current file. Is there a
way to kill it immediately (shell command, dll call, MBS command, ...)?
TIA for any advice/help.
_______________________________________________
_______________________________________________
_______________________________________________
_______________________________________________
_______________________________________________
Unsubscribe by sending a message to:
<nug-l

Continue reading on narkive:
Loading...