0

I've the following code which launches an exe

Runtime.getRuntime().exec("some.exe");

The problem is, I see a console which pops up for a while until some.exe is triggerred.

Options that I've tried so far

Runtime.getRuntime().exec("cmd /C /Q start /B some.exe")
Runtime.getRuntime().exec("cmd /C start some.exe")
Runtime.getRuntime().exec("cmd /c some.exe")

and none of them suppresses the console. I don't want to add a bat file that inturn will launch some.exe silently. Is there a way to suppress the console directly from Runtime.getRuntime().exec()?

SDS
  • 828
  • 3
  • 17
  • 35
  • If you open a command-prompt and simply run `some.exe`, does it open a new window there too? – Andreas Mar 07 '19 at 20:06
  • Usually the exe has some flag that allows it to run hidden. It does not sounds like the console is launched by Java – lalo Mar 07 '19 at 20:07
  • @Andreas No, `some.exe` does not open a command-prompt – SDS Mar 07 '19 at 20:10
  • @lalo you are right, Runtime exec is not launching the console and I verified this by creating a simple java class that runtime execs `some.exe`. I'm using http://launch4j.sourceforge.net/ to wrap some java code as an exe which then does some checks and finally calls `some.exe`. The console window is that of launch4j when it launches. I've to figure out a way now to suppress the launch4j console. – SDS Mar 11 '19 at 18:38
  • I found my answer, it was the headertype http://launch4j.sourceforge.net/docs.html that needed to be updated. I switched it to gui (I was using console) and I don't see any console now. Thanks all for the guidance. – SDS Mar 11 '19 at 18:47

0 Answers0