JSI Tip 0766. A better way to prevent more than one instance of an application from running.

Jerold Schulman

October 13, 1998

1 Min Read
ITPro Today logo in a gray background | ITPro Today

In tip tip 760, we prevented an application from starting if it was already running.

Using TLIST, is a better way. Here is a sample AppName.bat:

@echo off
tlist|find /i "appname.exe" > %TEMP%appname.tmp
for /f "Tokens=1-2*" %%i in (%TEMP%appname.tmp) do call :run "%%j"
start /wait /D [Other Switches and parameters] appname.exe
del /q %temp%appname.tmp
exit
:run
if /i %1=="appname.exe" exit
:end

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like