(view source code of lockprog.bat as plain text)
:: Check if program is locked, and by whom
IF EXIST LOCKED.BAT CALL LOCKED.BAT
:: Unlock if it was you yorself who locked it
IF "%LOCKEDBY%"=="%1" DEL LOCKED.BAT
:: Check again if program is locked, and by whom
IF EXIST LOCKED.BAT GOTO Locked
:: Lock it if it isn't locked by someone else
ECHO SET LOCKEDBY=%1>LOCKED.BAT
:: Start the program
:: (the first command line parameter, %1,
:: was used for this locking batch file)
MYPROGRAM.EXE %2 %3 %4 %5 %6 %7 %8 %9
:: Free the program
:: And quit
IF "%LOCKEDBY%"=="" GOTO Locked2
ECHO %LOCKEDBY% uses MYPROGRAM right now.
ECHO %LOCKEDBY% can free MYPROGRAM again by closing it normally.
ECHO Someone else has locked MYPROGRAM.
ECHO Contact your helpdesk or administrator.
page last modified: 2023-03-10