Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exit the batch file after running using java

I know how to start the batch file using java code. When i run the batch file command prompt is opened. To close the command prompt i am using the taskill /im cmd.exe. but the problem is that the command prompt that is used to start the jboss is also closed. i want to kill the cmd with a particular process id. How do i get the process id of a particular cmd promt and kill that using java


2 Answers

Run the batch file with cmd.exe /c job.bat. The /c switch carries out the command and then terminates the command interpreter.

like image 52
Zach Scrivena Avatar answered May 08 '26 02:05

Zach Scrivena


can't you add exit to your batch file to exit it's own command prompt. Uisng taskill seems overkill for just closing one command prompt, don't you think?

PS: I've never worked on batch files just the command prompt so I'm assuming it accepts the same commands.

like image 32
hhafez Avatar answered May 08 '26 01:05

hhafez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!