Java Stop Windows Shutdown

Mitch McCollum :

I have a odd problem. I want to detect when windows wants to shutdown and stop it from shutting down using java. I thought about using a shutdown hook and just run a command shutdown /a however it doesnt seem to be working.

kichik :

You need to respond to the WM_QUERYENDSESSION message and return 0.

You can do it with JNA.

Another example here: https://github.com/mirror/jdownloader/blob/master/src/org/jdownloader/osevents/windows/jna/ShutdownDetect.java

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=407354&siteId=1