Author Topic: Batch file  (Read 1214 times)

Offline T-Bag

  • also known as Teddy Bear
  • Retired Moderator
  • HolyShit Member
  • *
  • Topic Author
  • Posts: 6123
  • Country: gb
  • Karma: +617/-117
  • Awards Winner of 3 Photoshop Challenge Contests [RARE] GFX staff member [RARE] Timbersaw Tour Winner Award [RARE]
    • View Profile
    • Awards
Batch file
« on: July 11, 2013, 00:21 »
Hi guys, due to my laziness I made a wee batch file for starting multiple programs, but now I got stuck in 1 point.

Code: [Select]
start "DotaKeys" "TARGET"
PING 127.0.0.1 -n 1 >nul
start "Gproxy" "TARGET"
PING 127.0.0.1 -n 2 >nul
start "war" "TARGET"

well, its not perfect but it does its job...
so my problem is, that Im looking to kill DotaKeys after W3 or Gproxy is shut down. Most likely same way as Gproxy is killed after W3 is closed...does anyone know those magic lines for it?

PS: I have seen that in some batch files for this is used cmd echo (or smt similar) as first line, but I dont know what is that for, so if somebody knows...advice is welcomed.
Code: [Select]
@echo off

Thanks in advance...

Offline nekoo

  • Newbie Member
  • *
  • Posts: 7
  • Karma: +2/-0
    • View Profile
    • Awards
Re: Batch file
« Reply #1 on: July 12, 2013, 17:12 »
Hi,well the @echo off means that the echo is off(when you type something in cmd it says C:\path\path\ blabla when you type @echo off it doesn't say the path,bit clearer).
You could use something like this
tasklist /FI "IMAGENAME eq gproxy.exe" 2>NUL | find /I /N "gproxy.exe">NUL
if "%ERRORLEVEL%"=="1" taskkill /f /im DotaKeys.exe

Offline T-Bag

  • also known as Teddy Bear
  • Retired Moderator
  • HolyShit Member
  • *
  • Topic Author
  • Posts: 6123
  • Country: gb
  • Karma: +617/-117
  • Awards Winner of 3 Photoshop Challenge Contests [RARE] GFX staff member [RARE] Timbersaw Tour Winner Award [RARE]
    • View Profile
    • Awards
Re: Batch file
« Reply #2 on: July 12, 2013, 19:35 »
it doesnt work  :(
I tried this lane and it seems to be fine now...but ty for effort

Code: [Select]
:loop
ping -n 5 127.0.0.1 > nul
tasklist /FI "IMAGENAME eq war3.exe" 2>NUL | find /I /N "war3.exe">NUL
if "%ERRORLEVEL%"=="0" goto loop

taskkill /F /IM dotakeys.exe /T

Offline nekoo

  • Newbie Member
  • *
  • Posts: 7
  • Karma: +2/-0
    • View Profile
    • Awards
Re: Batch file
« Reply #3 on: July 12, 2013, 20:06 »
Well it's almost the same thing,just had to add :loop up and goto loop but whatevah

Offline T-Bag

  • also known as Teddy Bear
  • Retired Moderator
  • HolyShit Member
  • *
  • Topic Author
  • Posts: 6123
  • Country: gb
  • Karma: +617/-117
  • Awards Winner of 3 Photoshop Challenge Contests [RARE] GFX staff member [RARE] Timbersaw Tour Winner Award [RARE]
    • View Profile
    • Awards
Re: Batch file
« Reply #4 on: July 12, 2013, 20:24 »
yy, its same, but without loop, it didnt kill DK...

since its sorted....

« Last Edit: July 12, 2013, 20:30 by T_Bag »