I'm trying to stop a Windows service with an underlying java process with command net stop
. Sometimes the underlying process doesn't stop. I can only stop it by doing a taskkill /f /pid
.
What can I do instead ?
I'm trying to stop a Windows service with an underlying java process with command net stop
. Sometimes the underlying process doesn't stop. I can only stop it by doing a taskkill /f /pid
.
What can I do instead ?
Unfortunately your options are limited here.
Since your java application isn't a true Windows Service integrated with the Windows Service Control Manager, issuing a "net stop" will fail. Your java.exe will continue running and must be stopped by another method.
As you have pointed out, taskkill is one solution. When used without the "/f" parameter, taskkill should attempt to close java.exe gracefully.
Another option is to instruct your program to shut down using a custom method. For example if your program supports a web interface, you may be able to ask it to close by sending a request over the network.