Dan
Dan

Reputation: 1191

Ensuring application close in batch files

Specifically, I'm using DGIndex in a batch file as part of a sequence to do some video encoding.

Despite accepting CLI params, DGIndex pops up a window to do the processing. This then disappears when it's finished, but the command line hangs as though it's still open. The process is no longer running.

Is there something built-in that I can do to ensure it doesn't hang, or is there a third-party proxy utility that will monitor for a process end then close itself?

Upvotes: 0

Views: 762

Answers (3)

Shakesbeer
Shakesbeer

Reputation: 113

I had the same problem with DGIndex in batch files. I know this is an old question, but it seems DGIndex hasn't been updated since then, so this might still be relevant.

DGIndex has 2 different command-line "styles", in the manual one being called legacy (the one using upper case letters for the settings), the other UNIX-style (lower case letters).

For me, the "-exit" command of the UNIX-style command-line did not work, so that the batch file did not receive a corresponding message from DGIndex, even though it finished its job correctly. I used the legacy commands instead, and the problem was gone.

"Funny" that Dan had the problem with the legacy commands, so the other way round.

Regards, Mike.

Upvotes: 1

kodybrown
kodybrown

Reputation: 2603

If you use start, the batch file should return immediately after starting the dgindex application.

You can pass the /WAIT flag to start to it to tell it to wait until the process has exited before moving to the next line of the batch file.

start /WAIT dgindex -BF=[vob.txt] -FO=0 -IA=2 -OM=2 -TN=0 -OF=[out] -HIDE -EXIT

I know this is old, but did you ever get it figured out?

Upvotes: 0

Bali C
Bali C

Reputation: 31251

You could use something like this:

@echo off
echo Running program
start dgindex -BF=[vob.txt] -FO=0 -IA=2 -OM=2 -TN=0 -OF=[out] -HIDE -EXIT
ping 127.0.0.1 -n 10
taskkill /im dgindex.exe /f
exit >nul

This batch file basically runs the DGIndex program and then pauses for 10 seconds before attempting to close the program. Just replace the 10 with a delay of your choice, something long enough that if the program is still running it means it's crashed, then it will be closed after the delay.

I'm pretty sure you can't tell if the program has hung or not (at least not in batch anyways). This at least makes sure it isn't running if you need to run it again if it did crash.

Hope this helps!

Upvotes: 0

Related Questions