Any scripting command or method to retrieve file lock status?

Discuss and share scripts and script files...
Post Reply
Zardoz2293
Posts: 577
Joined: 09 Nov 2011 20:20
Location: USA

Any scripting command or method to retrieve file lock status?

Post 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!
Computer/Systems Background = Expert | Windows 10 Pro (64-Bit) | Dell Precision 7720

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

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

Post 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...
One of my scripts helped you out? Please donate via Paypal

Post Reply