Page 1 of 1

Any scripting command or method to retrieve file lock status?

Posted: 30 Dec 2016 18:37
by Zardoz2293
Is there any existing scripting command or example(s) of retrieving a files lock status. Example: a file is open and has any kind of lock flag, a return value from the call could be evaluated to know it is in fact locked.

Why? To prevent scripting commands which halt from trying to perform an action on a file which is locked. i.e., "renameitem"

Error "The process cannot access the file because it is being used by another process."

Thanks!

Re: Any scripting command or method to retrieve file lock status?

Posted: 30 Dec 2016 19:04
by highend
Windows brings "openfiles" (which is not really easy to use).
Handle (https://technet.microsoft.com/en-us/sys ... 96655.aspx) could be used and it's capable of
unlocking handles as well (but needs admin rights)
VBscript can't do it in a 100% reliable way...