Simple two program start batch file and task manager

Drivejunky95

Junior Member
Nov 21, 2015
1
0
0
EDIT:

CMD and BAT have /wait enabled by default so it's redundant.
Not all GUI will wait.
Could also be how the program.exe is programmed to exit.

Found this.

START "" /WAIT "C: /directory"
:CHECK
ping -n 10 localhost 1> NUL
TASKLIST /v /fi "IMAGENAME eq program.exe" 2>&1 > NUL
IF ERRORLEVEL 1 GOTO CHECK

If I understand it correctly it pings your running task list >10x for the specified program... then uses an if/then statement to either repeat the check or continue to the next line.

Since this would be running indefinitely for ~3 hours until closed would the check begin to slow down my computer at all? Using an SSD / AMD 8350.

Will try this tomorrow. If there is something more efficient/actually works please post, ty!

Hi everyone

I have a simple batch file in Windows 7. It reads:

cd /d "C: \directory"
Start Filename.bat

cd /d "H: \directory"
Start /wait program.exe

taskkill /f /im cmd.exe /t

Note: the space between Drive Letter and directory was causing a :\ to be written. no space in the actual bat file.

The "filename.bat" file is a looping xcopy that starts before the program.exe starts.

The problem is Start /wait program.exe does not wait until the application is closed before killing the looping cmd.exe

Have tried start /b /wait, and using CALL. No go.

program.exe is a Steam game (Fallout4Launcher.exe). I am thinking somewhere between the Fallout4Launcher.exe and Steam something is happening to restart the Fallout4Launcher.exe via Steam, and this causes the looping bat file to then terminate. Maybe?

The game in task manager is listed as Fallout4Launcher.exe

Am also considering there is some conflict in cmd environments, but I only know all of this as of today.

Last thought is start /wait waits until the program has executed, and then continues reading the bat. Although according to Microsoft the command "Starts an application and waits for it to end."

Open to any ideas or suggestions! Thanks!
 
Last edited:

sm625

Diamond Member
May 6, 2011
8,172
137
106
You shouldnt have to use "taskkill /f /im cmd.exe /t" since that is the last line of your batch file. The batch file should terminate the cmd automatically.

Since this would be running indefinitely for ~3 hours until closed would the check begin to slow down my computer at all? Using an SSD / AMD 8350.

Nope. Ping is a very small program. But if you want to cut down on resource usage, try using CHOICE instead of ping.

Code:
CHOICE /C ABCDN /N /T 5 /D c /M "Waiting 5 seconds..."
 
Last edited: