2

I have a batch file login.bat that contains

 java -jar D:/ERPLogin/Login.jar

The above code runs when the system starts it automatically running the my application. Similarly when user click the shutdown button from windows before run my application then system shutdown immediately with out user interface

Ramesh Somalagari
  • 525
  • 3
  • 11
  • 35
  • possible duplicate of [How to schedule a task to run when shutting down windows](http://stackoverflow.com/questions/101647/how-to-schedule-a-task-to-run-when-shutting-down-windows) – npocmaka Apr 29 '14 at 08:24

1 Answers1

0

Basically you will need to register your application as a service to receive Windows pre-shutdown notification. However, I donæt know if this is doable from Java (You will need to use The Tanuki service wrapper for java, I could not find in their documentation about this, the closes I got was: http://wrapper.tanukisoftware.com/doc/english/integrate.html), so you will need to create a new application in C or C# (I am not aware that any other programming language under windows provides this service, but please feel free to correct me if I'm wrong.)

The following links http://www.codeproject.com/Articles/106742/Creating-a-simple-Windows-Service and http://msdn.microsoft.com/en-us/magazine/cc164252.aspx explains this more or less the theory but uses Win32 API (the MSDN) which might be difficult for some to comprehend without necessary background.

http://www.sivachandran.in/2012/03/handling-pre-shutdown-notification-in-c.html gives an example in C#.

I recommend to go with the C# solution.

Ferenc Deak
  • 34,348
  • 17
  • 99
  • 167