Reputation: 669
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?
Upvotes: 3
Views: 2357
Reputation: 485
Process p = Runtime.getRuntime().exec("scriptName.vbs");
In scriptName.vbs you write
var WindowStyle_Hidden = 0
var objShell = WScript.CreateObject("WScript.Shell")
var result = objShell.Run("cmd.exe /c abc.bat", WindowStyle_Hidden)
Upvotes: 0
Reputation: 80633
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.
Upvotes: 1
Reputation: 2653
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/
Upvotes: 1