Processes do not close if started with PSExec

68 Views Asked by At

I have a batch file starting a long-running Java program. If this is started locally, directly on a PC by a user, it creates 3 processes visible in TaskManager: cmd.exe, conhost.exe and java.exe. If the user closes the command prompt window, all 3 processes terminate. This is expected behaviour.

However, if I start this batch file remotely from another PC using the PSExec utility, and the remote user is closing the command prompt window, all 3 processes remain running.

And if the remote user starts the same command again, I will have 6 processes, then 9, etc.

I would have expected that all 3 processes will terminate. However, this does not happen.

It is the long-running Java process which keeps all 3 processes running - if I terminate "java.exe" processes, all 3 processes disappear.

I believe this has something to do with the fact that closing the remote command prompt window is not directly connected to the running processes on the local computer.

To manually kill all 3 processes is not so easy, since there may be other Java processes running on that PC.

Is there any way to ensure the processes terminate once the remote command prompt closes?

0

There are 0 best solutions below