Not with built-in tools (there is nothing that can enumerate handles), but you can use the Sysinternals Handle tool to get a list of the PIDs that have open handles on a file. You can then parse the output with FOR /F
and use TASKKILL
to end the processes.
Example:
for /f "skip=4 tokens=3" %i in ('handle ..\logs\') do taskkill /pid %i
skip=4
skips the copyright information in Handle's output and tokens=3
picks out the PID from each line of output. The rest are self-explanatory.