I oftentimes want to start java GUI programs from a DOS Batch script. Therefore I put a code like this
in a DOS bacth script:
javaw.exe -jar mysample.jar parm1 parm2
which in turn starts java runtime and pass the *.jar (=java program) to it.
The disadvantage is that always a fat black Command prompt window appears on the screen which does not offer
anything execpt the start command echo.
What I want to achieve is that the Command Prompt window is silently suppressed and put completely into background. I even don't want to see it in (Win7) TaskBar.
If it is absolutely required it should be put automatically into SysTray.
How can I achieve this?
Extending the command above to e.g.:
start "" /B C:\WINDOWS\system32\cmd.exe /c "javaw -jar mysample.jar parm1 parm2"
does not help.
Furthermore I want to avoid shortcuts to the *.jar. So a batch script should be used somehow....
Peter
How to prevent popup of cmdprompt when executing dos script?
Moderator: DosItHelp
Re: How to prevent popup of cmdprompt when executing dos scr
This should close the cmd window on launch, if javaw doesn't use it.
Code: Select all
@echo off
start "" javaw.exe -jar mysample.jar parm1 parm2
Re: How to prevent popup of cmdprompt when executing dos scr
You could also create a shortcut with target ...
... and maybe the path of the jar file in the "start in" field (if there are any dependencies in the working directory).
This way you don't need the CMD at all and you could edit it as simple as a Batch file.
Regards
aGerman
Code: Select all
javaw.exe -jar "C:\wherever\mysample.jar" parm1 parm2
... and maybe the path of the jar file in the "start in" field (if there are any dependencies in the working directory).
This way you don't need the CMD at all and you could edit it as simple as a Batch file.
Regards
aGerman
Re: How to prevent popup of cmdprompt when executing dos scr
aGerman wrote:You could also create a shortcut with target ...Code: Select all
javaw.exe -jar "C:\wherever\mysample.jar" parm1 parm2
... and maybe the path of the jar file in the "start in" field (if there are any dependencies in the working directory).
This way you don't need the CMD at all and you could edit it as simple as a Batch file.
The problem with this solution is that f***ing Windows prepends AUTOMATICALLY and ALWAYS the
javaw.exe with the absolute path. So when you save the shortcut as above and re-open it you will find a cmd like:
Code: Select all
"C:\Program Files (x86)\Java\jdk1.7_17\bin\javaw.exe" -jar "C:\wherever\mysample.jar" parm1 parm
Now what if I update/install a new java version? Or jump to 64bit java? Or copy the jar program to other computers with different java path? Or run the jar GUI program from USB stick on another computer?
....then the above shortcut always fails.
Those dumb developers at Microsoft do not allow relative resp. path independent javaw.exe specifications.
Thats why I am searching for a dos batch script based solution.
Thx anyway
Re: How to prevent popup of cmdprompt when executing dos scr
pstein wrote:Thats why I am searching for a dos batch script based solution.
What didn't work about the suggestion I provided?
Re: How to prevent popup of cmdprompt when executing dos scr
@foxidrive: Your solution works (thank you) but not the one from aGerman
Re: How to prevent popup of cmdprompt when executing dos scr
Hi, pstein !
Use this command for ShortCut target instead:
Best wishes, Alex.
Use this command for ShortCut target instead:
Code: Select all
%SystemRoot%\system32\RunDll32.exe shell32.dll,ShellExec_RunDLL javaw -jar mysample.jar parm1 parm2
Best wishes, Alex.