when i run a .BAT file, it displays a message but immediately closes the window
how i can i force it to keep the window open so that i can see the message reeturned?
One way is to conclude the batch file with the
PAUSE
command.
You can also wrap it another batch file that calls the original and then pauses:
FOO.BAT
PAUSE
This also works for read-only batch files and compiled executables.
An alternative is to execute this bat file from an already opened command prompt (shortcut: Windows Key + R, type cmd, press ENTER)
Related
So I have a batch file that simply runs an exe file. I want to be able to open the command prompt, run the batch file, then... I want to type another command in the command prompt.
here is the code that is in the batch file called "sublime.bat":
"C:\Sublime Text 3\sublime_text.exe"
I open cmd in the directory with my bat file and I type:
"sublime.bat"
It works by opening sublime text but the cmd cursor starts flashing and I can no longer type anything until I close sublime text.
I want to be able to open sublime text and type commands out while still having sublime text open. Please help, thanks.
Command prompt doesn't execute a further line, while a command is on execution. It executes commands serially, not parallelly. So if you want a command to be executed cmd should return from executing previous one.
Here, in "sublime.bat" you have called a batch file which contains a command of executing another program. So, cmd waits for the result of executing the bat file and thus stuck there.
You can use start "/k" "C:\Sublime Text 3\sublime_text.exe" in your "sublime.bat". This holds only the start command and cmd gets free after starting the file.
I want to execute a batch file from another batch file and I have been successful in doing so but the problem is once the 2nd batch is executed the 1st batch window closes. I want to keep the first batch window to stay open
The command I am using is :
1st.bat :
2nd.bat "path"
pause
Try this:
start "windowname" "file.bat"
Sorry if this doesn't work; I'm currently using a mobile phone.
I currently have a Windows batch file that runs an .exe file that uses a text file. I am trying to have the Windows batch file run the .exe file multiple times. This, however, requires the use of the same text files to read from. The command prompt gives me the error that the ".txt could not be opened" (I assume from this that it is already open.)
I am trying to see if there is a way in a .bat file to system call to kill that specific text file. The suggestions I see online are to use 'taskkill notepad.exe', but that returns "invalid argument" because the program doesn't open Notepad to use the text file.
Any suggestions would be appreciated.
It sounds like your existing script fails because the first instance of the exe is still open when the second instance starts.
One thing worth trying (and this depends on the nature of the application you are invoking) is to start the executable using the START /WAIT /B ... command. This makes the command interpreter wait for the program to exit before it moves onto the next command, so as long as nothing else is locking the text files you should be OK to move onto the next command.
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.