batch file START command without /WAIT - batch-file

I need to start an exe from a batch file and after it has run it, I want the CMD prompt to exit, without waiting for the application to exit.
By just entering the location of the EXE does not work, it seems to wait for it to exit.
Is there a way to not do that with the START command?

Use CALL instead of START
call notepad.exe
echo byby
exit

Related

How run batch script to get output in text file

Below executable return string values in command but when i execute below batch script it pop up different command line console and exits hence i am not getting any values in output.txt
how to capture this result ?
c:\
cd C:\Windows\System32
start usbinvoke.exe argument >c:\result\outpput.txt
pause
usbinvoke.exe argument > C:\result\output.txt
Start starts programs in unusual ways. See start /?
See Command to run a .bat file
Your other commands are unnecessary.
You right click a shortcut to cmd and tick Run As Administrator on the compatibility tab
c:\
cd C:\Windows\System32
usbinvoke.exe argument >c:\result\output.txt
pause
start does not wait unless you use /wait argument. Suggest remove start and just run the executable.
You cannot redirect streams with a process that does not wait as the no handle is attached to the process.
If you require start then use arguments /b (same window) and /w (same as /wait).

Executing bat files one by one

What I got is a list of bat files:
file1.bat
file2.bat
…
file29.bat
I need them to run one after each other. Meaning when the file1.bat closes file2.bat starts and so on.
I tried this, but it doesn't work properly:
start /wait call file1.bat
start /wait call file2.bat
You might want to add more to your question to make it easier to understand. My guess is that you want the bat file to open the next one then close itself after that.
If that's what you want to do; add these commands to each of the files:
start file2.bat
exit
Of course, you'll want to change start file2.bat to start file3.bat and so on for each file.
If you want file1.bat to manage all of the files, I don't think that's possible in batch.
You didn't describe how exactly it's not doing what you expected. I'm guessing that what happens is you're having to shut down each script before the next one will continue.
Documentation on start says:
WAIT Start application and wait for it to terminate.
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.
If you must use start then you could force it to use the /c switch which will automatically close the window once it's done:
start /wait cmd /c call file1.bat
I'm not really sure you accomplish anything by using call so that ought to be equivalent to just:
start /wait cmd /c file1.bat
Using start creates a new window for each program and you may just want to have it all run in a single command processor window.
As noted by Biffin you can just list them all out in a master script and they will run in order.
call file1.bat
call file2.bat
...
call file29.bat
And a shorthand for that is:
for /l %%f in (1; 1; 29) do call file%%f.bat
Remember to double up those percent characters inside a batch script but not on the command line.
This question might explain some of the unexpected behavior you were seeing.
How to run multiple .BAT files within a .BAT file

Run process in its own window

I was playing around with Batch on my computer, and I wanted to run a process in its own window. I figured out how to get it to run in its own window, but I want the window to close when the process ends. How can I do this?
This code will run python 2's python.exe in its own window:
#echo off
start call "C:\Program Files\Python27\python.exe" %*
Is there a way I can assign the new window to some variable and check if it has finished running the process, then exit the new window?
START via CMD /C, and the window will close once the command ends.
Also, as Endoro said in his comment, you should not need CALL
#start cmd /c "C:\Program Files\Python27\python.exe" %*

calling batch script from a batch script without pausing the execution of parent script

I want to call a batch2 script from a batch1 script in special case , but dont want wait parent batch1 script to wait for completion of batch2.
Want batch1 to move to next command while batch2 run in Parallel.
The NT shell command START will pass the batch file to its own Window for execution and immediately proceed to the next line.
start 1.bat
start 2.bat
You can use start like this
echo batch1 command
start batch2.bat
echo batch1 carries on whilst batch2 runs at the same time
Start command starts the 2nd batch file in the other window and both runs in parallel
#echo off
::This is the second batch file that runs in parallel with this file
start batch_file.bat

Invoke EXE from batch file *without* waiting

How do I invoke an EXE from a batch file without having the latter waiting for the EXE to finish? Something like the Cygwin 'cygstart'?
Use "start". Type "start /?" at a command prompt.
put START /B before the command you want to run
Just start foo.exe? You need to add /WAIT to make it pause.

Resources