We have an application that creates a lockfile, and while that lockfile exists, you can't operate on other files within the application. So, copying data files, extracting them to read, etc can't be done while it exists.
We were using a workaround that uses ShadowCopy (VSS) to allow us to ignore the lockfile, copy the files, and read them. Now we've run into an issue at one of our locations, where VSS doesn't play nicely on a Virtual Machine and throws errors.
How do I perform realtime monitoring of a Server directory, in order to perform an action as soon as a lockfile no longer exists, using only native commands or utilities?
EDIT: Based on a comment that was removed, I'm thinking it should go something like this, in a batch executed daily:
:WaitLoop IF NOT EXIST "path\to\app.db$-lock" TIMEOUT /T 1 /NOBREAK ( ROBOCOPY "path\to" "path\to\Files" *.V2$ *.DA$ *.DI$ *.IX$ /E /XO /MT:16 > "path\to\Files\robocopy.log" & GOTO BreakLoop ) GOTO WaitLoop :BreakLoop EXIT
This is different than a lot of monitoring questions I found, because it's looking for a file to not be there. The /MON of robocopy won't help in that case, for instance, since as far as I can tell, it monitors all changes.
This answer worked, modified slightly.
https://superuser.com/a/983625/117443