I have the following batch script:
start "" "C:\eBroadcaster\EBroadcaster1.exe" -S"ASDFSQL";-D"MAILman_PROD";START
Open in new window
How do I get the batch to search for another instance 'EBroadcaster1.exe' and to terminate if finds one currently running, to prevent the program from running two instances of itself?
Any help is welcome.
Check for the existence of "flagfile.txt" in a directory to which it has write access. If it finds the file, exit.
Create the file. No content is necessary; the existence of the file is the flag.
When done processing, delete the file in the closing cleanup code.
This is crude but easy to implement. The problem is that if the program is aborted or terminates abnormally, the flag file remains unless the program catches the abort command and deletes the flag file in the abort handling code.