(view source code of lockprog.bat as plain text)
@ECHO OFF
:: 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
SET LOCKEDBY=
DEL LOCKED.BAT
:: And quit
GOTO End
:Locked
CALL LOCKED.BAT
ECHO.
IF "%LOCKEDBY%"=="" GOTO Locked2
ECHO %LOCKEDBY% uses MYPROGRAM right now.
ECHO %LOCKEDBY% can free MYPROGRAM again by closing it normally.
GOTO Errors
:Locked2
ECHO Someone else has locked MYPROGRAM.
ECHO Contact your helpdesk or administrator.
:Errors
ECHO.
PAUSE
:End
page last modified: 2024-04-16; loaded in 0.0066 seconds