Batch file works for 1 thing, Not! for another.....


May 21, 2013
Well, So I am trying to automate starting a game with a trainer, mostly to see if I could, however, I have run into an annoyance and was curious if anyone could figure out why...for me... or help me =)
The issue: setup works great with a test setup, and not at all with the desired setup.
What i think it may be: I believe, the 'call' function in the batch, in the test setup it runs the "called" bat and waits for it to finish before proceeding, in the desired setup, it runs the "called" batch but continues on without waiting for it to finish.

My setups:
-Test: run a game trainer (first exe file), wait a sec, call batch that runs testMC.exe (is minecraft...) when testMC.exe(javaw.exe) closes batch continues back to first batch and closes trainer then exits.
-Desired: run the trainer, wait, call batch to run game (darksouls), darksouls exits,etc(as above)

As i stated per my issue, it just runs right through the called batch file, running the game but not the code in the called batch, thusly closing the trainer and finish the batch while the game is still open.

My batch files:
First or launcher
@echo off
title Darksouls w/ trainer
set game=Darksouls
start trainer.exe || goto error
ping -n 1 -w 1000 > nul
echo (%date%)(%time%) %game% is now running
echo Waiting for %game% to close...
call called
taskkill /f /im trainer.exe
goto close
echo error
echo Failed to start
SET "A="
SET /P A=Do you wish to (1)exit or (2)retry: 
ECHO Waiting for selection .........
IF "%A%"=="1" exit
IF "%A%"=="2" goto start

and the called bat that waits for the game to close

@Echo Off
Set _ChkInt=10
Set _MaxWait=60000
Set _ProgName=DARKSOULS.exe
Set _ImgName=DARKSOULS.exe 
Call :_FixName "%_ImgName%"
Set /A _PWait=_ChkInt*1000
Set _TotalWait=0
Start "" "%_ProgName%"
Ping -n 1 -w %_PWait%>Nul
Set /a _TotalWait+=_ChkInt
If %_TotalWait% GEQ %_MaxWait% Goto Continue
tasklist /NH /FI "IMAGENAME eq %_ImgName%" 2>Nul|Find /I "%_ImgName%">Nul
If %ERRORLEVEL%==0 Goto WaitLoop

Echo Waited %_TotalWait% Seconds Or %_ProgName% Exited
Goto :EOF

Set _ImgName=%~nx1
Goto :EOF

So, to clarify what I am trying to do.
1. I want to start a trainer.exe
2. wait for it to load
3. call a batch that starts the game
3a. (loop) check if the game is running
3b. when game is not running, 2nd batch finishes, back to finish first batch
4. close trainer
5. exit

Thank you all for any insight.

P.S. Darksouls runs as DARKSOULS.exe and DATA.exe, I've tried both as _progname neither work. MC runs as javaw.exe, so it starts with a dif exe but i cant see that effecting this process.

EDIT: Also, the batch that checks if the game is still running works just fine.
A link to a text log, LOG


May 21, 2013
Well shoot!
So of course I was just stupid, it all worked just fine....
the call command was 'call DARKSOULS'. thats what i named to listener batch, but it is also the games exe name, so i changed the batch name and it works beautifully now.

Have not yet seen a setup like this on the net before so go ahead and use it. I see more potential in it than just auto run/close a trainer with game launch.