Execute a batch file from another batch while keeping previous console open - batch-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.

Related

How to **not** change the title bar in command prompt when running bat file

When I use the standard command prompt in Windows and run a bat file (or a bat file that runs a second one) the title bar in the console window changes to the name of the script being run. While I can set the title to anything I want using the TITLE command, that's overriden when running a bat file.
Without modifing the called bat file, how can I preserve the previous title and avoid the change?
Edit
As for why would I want this, let's suppose I have a bat file which sets the console title (for ease of identification) and in turn calls another bat file. During that second bat file execution, the title is lost.
#ECHO OFF
TITLE My bat file is running
REM Some commands run here, custom title is OK
REM Here title is lost and replaced by "AnotherFile"
CALL AnotherFile.bat
REM When the call returns, my custom title returns here
REM More commands with my title again
Question is, how can I preserve the title during the CALL?

Why can't I use the command prompt after running a batch file on it?

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.

Batch Files - Closing Opened Text Files

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.

how to execute cmd commands and compile it in a .bat file

Hello I'm getting sick from repeating commands in the cmd window so I want a .bat file that makes cmd opens then execute the command, and would be great if it's closed after executing the commands like example:
ipconfig/release
ipconfig/renew
Then closes the cmd window
Thanks.
Easy:
Put both commands in a text file, name it "new.bat".
Add a #echo off and a exit, and you are done:
#echo off
ipconfig/release
ipconfig/renew
exit
Every time, when you enter new, it will execute these commands.
And you can even do it with a double-click in WindowsExplorer.
You could save the .bat file to the desktop, so you can reach it easy with your mouse.

getting returned results after running .BAT file

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)

Resources