Kill or close 100 CMD windows being opened in squence

batchcmd.exe

I'm doing an operation that will open 100 Dos windows in sequence (one after the other is finished).

Each window will take approximately 2 hours to complete the process, then the next window starts, and so on.

I would like to close each right after it starts. Is there any way I can automate the process of closing the dos windows?

UPDATE: I'm running a software that opens a DOS window to perform an operation, upon opening the DOS window the software writes a batch file. This will happen about 100 times because I setup the software to perform 100 different operations.
I'm going to use all 100 batch files later. I need to automate the closure of the DOS windows. I don't really need those windows, I only care for the batch files being written.
Hope this clarifies the issue.

Best Answer

If you're using GOTO EOF at the end of your scripts that are executed, you can simply replace that with EXIT /B instead and that should work for your need.

Example Script

@ECHO ON 
SET RootDir=C:\Folder

FOR /F "TOKENS=*" %%A IN ('DIR /S /B "%RootDir%\*.bat"') DO START "" "%%~A"
EXIT /B

EXIT

Quit the current batch script, quit the current subroutine or quit the command processor (CMD.EXE) optionally setting an errorlevel code.

Syntax

EXIT [/B] [exitCode]

Key

/B        When used in a batch script, this option will exit 
          only the script (or subroutine) but not CMD.EXE

exitCode

          Sets the %ERRORLEVEL% to a numeric number.
          If quitting CMD.EXE, set the process exit code no.

source

Related Question