@echo off if +%TEMP%==+ set TEMP=%TMP% if exist %TEMP%\lock_$_$.cmd goto RUNNING copy %1 %TEMP%\lock_$_$.cmd > nul del %1 call %TEMP%\lock_$_$ del %TEMP%\lock_$_$.cmd goto GETOUT :RUNNING echo/ echo It seems that another instance of this batch file is already running. echo If this is true, please wait until it finishes and then run this batch echo file again. If on the other hand this is not true, delete the file echo %TEMP%\lock_$_$.cmd and then run this batch file again. echo/ pause :GETOUT