-1

Okay so I know nothing really about batch files and I am making one for something. It is a very small batch file which executes two programs and what I want it to do is execute another program (or command) if those programs are no longer running. How do I specify in the batch file "if this program is not running... then... execute this command"???

PS: I know this is basic but I know pretty much nothing...

Here is what I need to be turned into a proper batch:

START "%CD%\Chaoslauncher.exe"

If "Chaoslauncher.exe" is closed off and Starcraft.exe is not running then END BATCH

IF "Starcraft.exe" is running execute:

"%CD%\dc64.exe" -width=800 -height=600 -depth=32 -refresh=60

WHEN Starcraft.exe is closed off and "Chaoslauncher.exe" IS running close off "Chaoslauncher.exe" and execute:

"%CD%\dc64.exe" -width=1600 -height=900 -depth=32 -refresh=60

AND END BATCH

IF "Chaoslauncher.exe" isn't running while "Starcraft.exe" is running end "Starcraft.exe" execute the command:

"%CD%\dc64.exe" -width=1600 -height=900 -depth=32 -refresh=60

THEN END THE BATCH

Also at ALL times keep CMD window hidden.

Radical924
  • 65
  • 1
  • 3
  • 12

1 Answers1

0
@ECHO OFF
SETLOCAL
"%CD%\dc64.exe" -width=800 -height=600 -density=32 -refresh=60
"%CD%\Chaoslauncher.exe"
TASKLIST /v|FIND /i " "Chaoslauncher.exe" >nul
IF ERRORLEVEL 1 GOTO launch
TASKLIST /v|FIND /i " "Starcraft.exe" >nul
IF NOT ERRORLEVEL 1 GOTO :eof
:launch
"%CD%\dc64.exe" -width=1600 -height=900 -density=32 -refresh=60
GOTO :EOF

This should fulfill your goal.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • In order to execute a command after the executable has been terminated, you'd need to keep the `.bat` running hence you'd need to 'run invisible' [so] (http://stackoverflow.com/questions/411247/running-a-cmd-or-bat-in-silent-mode). I'd try that method. ISTM you'd need to execute `dc64` and **THEN** `chaoslauncher`. According to `12noon`'s site, there is no such switch as `density` - perhaps you mean `depth`? It would also appear that returning the monitor state is **OPTIONAL** but there's no indication of **HOW**. There is also an example of how to usec `dc64` to launch an executable. – Magoo Jul 30 '13 at 21:12
  • I had to edit the post to further clarify maybe it'll make more sense? Idk but if you could modify your answer to reflect the more clear post it would help... and your current answer didn't work btw... =( – Radical924 Aug 15 '13 at 04:47