I would like to run program from windows console(cmd.exe) and close console after that. now when i do it the console stays opened as long as the program is running.
I would like it to start program, close console and use program.
I double click the batch
#c:\somedir\app.exe
Use start
START "title" [/Dpath] [options] "command" [parameters]
Example: start /B "Test" program.exe
http://ss64.com/nt/start.html
I'm not running Windows right now so I can't try it out, but have you looked into start? You can find more information here.
Another option might be call.
Related
I think it's a simple question, but I don't realize its solution.
I have a batch file that calls an EXE program. It's working fine, but I'd like to close the CMD window without having to click on it.
It's like this:
#echo off
[...]
call EXEprogram.exe
[...]
exit
I want the CMD window vanishes, even if the EXEprogram is still running, but the control doesn't return to the batch file, to execute the EXIT command. I tested using CALL command calling another batch file that calls EXEprogram and also, don't using the CALL command, but result is the same: CMD window shows that EXEprogram is still running and the control doesn't come back to execute EXIT command.
Ideas?
Use the start command instead of call:
start EXEprogram.exe
Type start /? for further details.
I have a small Windows batch script that is executed from within a game application (the user experience is important here) that is called to start a Java program among other things. With the command javaw I hide console output from the user of the game to improve experience, however, the console window remains open from the batch file execution and doesn't close until the Java code is finished executing.
The first solution I tried was to use the start command, but I am unable to pass any parameters to the java program and it fails accordingly.
start javaw -jar jar-file-here.jar args...
How should I write a batch file that will start a Java program with the correct variables, and close without waiting for Java to close?
Edit:
My parameters contain quotes ( " ), so I am unable to contain them all in quotes without confusing the command.
The first argument accepts a window title. Here is the command with the adjustment made:
start "Window Title Here" javaw -jar jar-file-here.jar args...
Specifically, I'm using DGIndex in a batch file as part of a sequence to do some video encoding.
Despite accepting CLI params, DGIndex pops up a window to do the processing. This then disappears when it's finished, but the command line hangs as though it's still open. The process is no longer running.
Is there something built-in that I can do to ensure it doesn't hang, or is there a third-party proxy utility that will monitor for a process end then close itself?
I had the same problem with DGIndex in batch files. I know this is an old question, but it seems DGIndex hasn't been updated since then, so this might still be relevant.
DGIndex has 2 different command-line "styles", in the manual one being called legacy (the one using upper case letters for the settings), the other UNIX-style (lower case letters).
For me, the "-exit" command of the UNIX-style command-line did not work, so that the batch file did not receive a corresponding message from DGIndex, even though it finished its job correctly. I used the legacy commands instead, and the problem was gone.
"Funny" that Dan had the problem with the legacy commands, so the other way round.
Regards, Mike.
You could use something like this:
#echo off
echo Running program
start dgindex -BF=[vob.txt] -FO=0 -IA=2 -OM=2 -TN=0 -OF=[out] -HIDE -EXIT
ping 127.0.0.1 -n 10
taskkill /im dgindex.exe /f
exit >nul
This batch file basically runs the DGIndex program and then pauses for 10 seconds before attempting to close the program. Just replace the 10 with a delay of your choice, something long enough that if the program is still running it means it's crashed, then it will be closed after the delay.
I'm pretty sure you can't tell if the program has hung or not (at least not in batch anyways). This at least makes sure it isn't running if you need to run it again if it did crash.
Hope this helps!
If you use start, the batch file should return immediately after starting the dgindex application.
You can pass the /WAIT flag to start to it to tell it to wait until the process has exited before moving to the next line of the batch file.
start /WAIT dgindex -BF=[vob.txt] -FO=0 -IA=2 -OM=2 -TN=0 -OF=[out] -HIDE -EXIT
I know this is old, but did you ever get it figured out?
I have creted a batch file that I want to run the SetupCodeGroup.exe
When I double click the batch file it doesnt run the exe file. A command prompt opens up but it doesnt run the file. Can someone tell what I missed or what I am missing
C:\Users\raw008\Desktop\Critcare\SetupCodeGroup.exe
type pause on the next line and check whether this executable comes on the command prompt .
try
start C:\Users\raw008\Desktop\Critcare\SetupCodeGroup.exe
moreover
start /d "path_to_file_directory" program.exe
is the complete line to execute program and console will not wait to program to exit .
I wonder if this exe requires administrative privileges. Try right-clicking the batch file and running it as administrator.
#echo off
start C:\Users\raw008\Desktop\Critcare\SetupCodeGroup.exe
echo Done
pause
try that if that dose not work then your computers privleges are messed up, i ran into the same problem on my cousins computer.
I have a *.exe console file.
I enter my inputs, and everything is great.
but when I enter the last input, the command window closes (because the program has ended)
before I can read the last output.
is there a way to run that *.exe file and force it to stay open after the program ends?
note: this is not my program. I can't edit the source code, so I'm not looking for answers like "add while(1) or scanf at the end".
Thanks ahead.
Just open a command prompt and run it, the way it's meant to be used.
Start -> Run -> cmd.exe
or Win+R -> cmd
Run the program from command prompt (Start-Run-cmd.exe)
Make a batch file (*.bat), with the command you want to execute, followed by pause:
myconsoleapplication.exe
pause
Save it, and run. The command window wil wait for enter to be pressed before closing.
Run it from the console, or in a batch file.
Start >> Run >> cmd.exe
Then the console window is already open.
This should work:
system("pause");
At the top of your program, include stdlib.h:
#include <stdlib.h>
You can open a command prompt window and navigate (the cd command) to the directory containing the .exe file. Then, run the program by typing its name. The window will not close after the program finishes running.
You could execute this program from one of your own, redirecting stdio and adding your own pause after it terminates. I've done this with .NET but assume that it can be done through other means. Of course a batch file, as mentioned already, is wicked simpler.