In a Java application:
currentProcess = Runtime.getRuntime().exec("MyWindowsApp.exe");
...
currentProcess.destroy();
Calling destroy simply kills the process and doesn’t allow any user cleanup or exit code to run. Is it possible to send a process a WM_CLOSE message or similar?
You could use Process.getOutputStream to send a message to the stdin of your app, eg:
Of course this means you have to contrive to listen on stdin in the Windows app.