Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide BAT file window when invoking it from Java

I'm invoking the execution of a BAT file from Java with the Runtime object.

Is it possible to hide the BAT window during the execution of the script? How is it possible?

like image 893
r.rodriguez Avatar asked Jul 19 '26 08:07

r.rodriguez


2 Answers

Try using javaw rather than java to run the script.

http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/java.html

Update: Sorry, I think I read the question wrong. I know I've suppressed a .bat window doing something along these lines before:

http://www.geekstogo.com/forum/topic/56092-hide-the-command-prompt-windows/

like image 171
aglassman Avatar answered Jul 20 '26 22:07

aglassman


Invoke start as the first command in your process builder, with the /b option:

ProcessBuilder builder = new ProcessBuilder("start", "/b", "<mybatchcommand>");
// .. set environment, handle streams
builder.start();

The /b options suppresses the command window.

like image 26
Perception Avatar answered Jul 20 '26 20:07

Perception



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!