4

I want to run a jar file with a .bat (the jar file doesn't seem to want to open on its own but thats a different issue for now) but as the java file runs for a long time, the command prompt remains open (while the .bat/.jar is still running)

I do not want this.

I read somewhere that you can use a .cmd file and the command(s):

cmd /c bat.bat
exit

To run a bat file without a command prompt. But that isn't working for me. When I click the .cmd program it just opens a command promopt and keeps printing "cmd /c bat.bat exit" over and over in a loop.

What am I doing wrong, was my .cmd command wrong? Is there another way to run a .bat without a command prompt remaining open?

Thanks alot.

Riking
  • 2,389
  • 1
  • 24
  • 36
James Andrew
  • 7,197
  • 14
  • 46
  • 62
  • I tried to retag your question to put `batch-file` in front, but it seems like StackOverflow wants to keep it in this order. Dunno. – Riking Mar 06 '13 at 01:54

1 Answers1

6

From here:

Save the following as wscript, for instance, hidecmd.vbs after replacing "testing.bat" with your batch file's name.

Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd /c testing.bat"
oShell.Run strArgs, 0, false

The reference is here http://msdn.microsoft.com/en-us/library/d5fk67ky.aspx

Community
  • 1
  • 1
vinnydiehl
  • 1,654
  • 1
  • 13
  • 17
  • 1
    I found this question to have a better answer. use the start command: http://stackoverflow.com/questions/12314638/close-a-batch-file-after-running-the-jar-file – n4rzul Aug 20 '14 at 15:58