Yes, that would certainly solve the problem, but the other alternative -- to
not use -t
-- would also work.
The reason that the program cannot kill the process started by ShellExecute is that the process handle returned is that of Cmd.Exe -- not Ping.Exe. Killing Cmd.Exe will not kill Ping.Exe.
That's no big deal... just use CreateProcess or ShellExecute passing Ping.Exe as the program. But alas, Develprog thinks he needs to use redirected I/O and that to make that happen, he thinks he must use
>temp
in the command line. Alas, that only works when using Cmd.Exe as the program.
So there are two simple solutions:
1) Don't use Ping -t
Instead run the Ping command (without -t) again and again. The result would be as desired.
2) Do use Ping -t, but handle the redirection via the technique described here.
3) Don't use Ping.Exe at all. Instead write program code that does the same thing. I'm afraid that this technique would complicate the program beyond the apparent programming expertice level of the asker.
4) There is an alternative that nobody has suggested yet... I'd never suggest this except that the good solutions have already been rejected:
To kill the ping -t command execute this: