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

j_a_k_e_24

Honorable
May 21, 2013
2
0
10,510
0
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
CSS:
@echo off
:start
title Darksouls w/ trainer
set game=Darksouls
start trainer.exe || goto error
ping 1.1.1.1 -n 1 -w 1000 > nul
echo.
echo.
echo (%date%)(%time%) %game% is now running
echo Waiting for %game% to close...
call called
taskkill /f /im trainer.exe
goto close
:error
echo error
echo.
echo.
echo.
echo.
echo Failed to start
echo.
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
:close
exit
and the called bat that waits for the game to close

CSS:
@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%"
:WaitLoop
Ping 1.0.0.0 -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
:Continue

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

:_FixName
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
 

j_a_k_e_24

Honorable
May 21, 2013
2
0
10,510
0
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.
 
Thread starter Similar threads Forum Replies Date
David___Only Apps General Discussion 0
S Apps General Discussion 4
M Apps General Discussion 3
D Apps General Discussion 2
N Apps General Discussion 1
NoctisLionward Apps General Discussion 2
malavena Apps General Discussion 3
Tom Waller Apps General Discussion 2
P Apps General Discussion 1
S Apps General Discussion 4
A Apps General Discussion 13
Z Apps General Discussion 1
P Apps General Discussion 7
G Apps General Discussion 0
T Apps General Discussion 5
SHADOWSTRIKE1 Apps General Discussion 3
S Apps General Discussion 3
R Apps General Discussion 3
P Apps General Discussion 2
M Apps General Discussion 3

ASK THE COMMUNITY