How to check in command-line if a given file or directory is locked (used by any process)?
I need to know that before any attempt to do anything with such file. dbenham Not sure about locked directories (does Windows have that?) But detecting if a file is being written to by another process is not difficult. @echo off 2>nul ( >>test.txt echo off ) && (echo file is not locked) || (echo file is locked) I use the following test script from another window to place a lock on the file. ( >&2 pause ) >> test.txt When I run the 2nd script from one window and then run the 1st script from a second window, I get my "locked" message. Once I press <Enter> in the 1st window, I get the "unlocked"