Mehul Parmar
Mehul Parmar

Reputation: 380

How to capture close event while running a jar file using bat

I have made a bat file to run a jar file. Whenever a user closes cmd using the close button, I want event should be logged. How do I capture this?

Upvotes: 0

Views: 214

Answers (1)

jwdonahue
jwdonahue

Reputation: 6669

Only way I can think to do this is to run a monitor script:

@start /WAIT cmd.exe batch.cmd args
@rem Do whatever logging needs to happen here.

Depending on how you start the monitor, you can arrange to hide that from the user so they can't kill it. Take a look at start /? for the range of options you can use.

Upvotes: 1

Related Questions