@echo off
if exist %TEMP%\lock_$_$.bat goto RUNNING
copy %1 %TEMP%\lock_$_$.bat > nul
del %1
if exist %TEMP%\error$_$ del %TEMP%\error$_$
%COMSPEC% /e:2048 /c %TEMP%\lock_$_$
del %TEMP%\lock_$_$.bat
if exist %TEMP%\error$_$ goto ERROR
rem
rem The next command instructs dviwin to re-read all the fonts. If you
rem normally start dviwin with the "-1" command line switch, then you
rem need to specify the same switch here too. This operation is valid
rem only under NT, so we test for the OS environment variable.
rem
if not +%OS%+==++ dviwin2 -1r
goto GETOUT
:ERROR
del %TEMP%\error$_$
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_$_$.bat and then run this batch file again.
echo/
pause
:GETOUT
