I've got a batch script start.bat
that creates a locked .lock
file (basically, to verify if the script is running, by attempting to delete it) and starts a bunch of secondary looping batch scripts (they keep on running after start.bat
is closed). The problem is when start.bat
is closed the locked file remains locked, until ALL of the secondary scripts are closed.
Question: Are there any alternative methods to run secondary batch scripts without locking up the primary script until secondary ones are finished?
I feel like most of this code is irrelevant, but included it in case somebody wants to test it.
@echo off
set "started="
<nul >"%~nx0.lock" set /p ".=." ::Rewrite lock file with a single dot
2>nul (
9>>"%~f0.lock" (
set "started=1"
call :start
)
)
@if defined started (
del "%~f0.lock">nul 2>nul
) else (
exit //script closes
)
exit /b
:start
//irrelevant loop logic
Start pause.bat //Pause command to keep pause.bat open
//starts other batch files too