deepaksharma
deepaksharma

Reputation: 311

Execute batch file silent in background

Below are the batch file code.....

cd\
cd C:\Program Files\Project
"C:\Program Files\Project\jre\bin\javaw.exe" -classpath .;Project-jar-with-dependencies.jar;javafx-2.2.jar; com.ui.main.Main

Problem: When i click on the batch file, CMD window open (black screen) but i want to execute that batch file silently in background means CMD window should not open.

A few suggestion are mentioned on Google but that execute the batch file using VB script but i do not want that solution.

Any suggestion. Thanks in advance.

Upvotes: 0

Views: 11000

Answers (3)

user11376279
user11376279

Reputation:

@echo off > nul

should do the trick (put it at the beginning of the batch file

Upvotes: 0

dave_thompson_085
dave_thompson_085

Reputation: 38821

Some simple answers that don't exactly "not open" but may be close enough.

  1. create a shortcut to your batch file and in its Properties change Run to Minimized, and use it. The CMD window appears in the taskbar but not on the desktop.

  2. since you only want to run one (nonconsole) executable, use 'start' to start it, then the batch file exits while the program (javaw) continues running. The CMD window flashes briefly and then disappears.

  3. do both. The CMD window flashes briefy in the taskbar.

Also: If you are (or will be) using JRE 7 from Sun^WOracle, it now has javafx included and you don't need your own copy.

Upvotes: 2

Marco de Abreu
Marco de Abreu

Reputation: 663

A .bat file needs cmd.exe in order to get processed. There is no way to hide its output window if you are executing it without an external host (like you've mentioned about VB). There would be different approaches to hide the window when it shows up, but this would require another application and be a very messy solution.

Upvotes: 0

Related Questions