Service Logstash with exit code 1 when restarting

hi community

I need advise from community about logstash
I create logstash as a service using NSSM in Windows Server 2016.
Then I usually use(start/stop/restart) it via services panel.

Now I can not restart anymore.
Let me share the windows event viewer logs.

D:\elk\logstash-6.1.1\bin\logstash.bat exits. RegisterWaitForSingleObject() failed: The parameter is incorrect.
Killing process tree of process 5404 for service Logstash with exit code 1
Killing PID 5404 in process tree of PID 5404 because service Logstash is stopping.
Program D:\elk\logstash-6.1.1\bin\logstash.bat for service Logstash exited with return code 1.
Started D:\elk\logstash-6.1.1\bin\logstash.bat -f D:\elk\logstash-6.1.1\bin\my-pipeline.conf for service Logstash in D:\elk\logstash-6.1.1\bin.

When I restart via command prompt, it is fine.
But I want to use via service. How do I get it back?
Looking forward to reply...

Thank you.

Oh I know why now
It seems jre update.
When logstash stop and restart again, it becomes JAVA_HOME variable path is not correct.
After editing JAVA_HOME variable, it works properly.

That is an NSSM error. It is not clear that logstash has anything to do with this.