Andy
Andy

Reputation: 3682

close cmd after running bat self-destructing bat from Java

In my Java application, I create a temporary batch file which does some work for me and the self deletes using this line del /f /q %0. The bat file is launched using ProcessBuilder and then System.exit(0) is called.

This workflow works perfectly, however once the batch file reaches the end I am left with a command prompt window saying "The batch file cannot be found" and waiting for another command. Is there any way I can stop this from happening?

Upvotes: 1

Views: 439

Answers (1)

Stephan
Stephan

Reputation: 56180

del /f /q %0 &exit

should help

Upvotes: 1

Related Questions