Test if a file is locked in VBscript?
Posted on 2006-10-23
I got this vbscript:
Set FSO = CreateObject("Scripting.FileSystemobject")
' my objective the windows temp folder
Set objFsoFolder = FSO.GetFolder("C:\Windows\Temp\")
Set objFsoWindowsTemp = objFsoFolder.SubFolders 'collection of subfolders I don't use
On Error Resume Next
For Each file In objFsoFolder.files
' IF FILE NOT locked THEN
msgbox("Done deleting batch files")
Set FSO = nothing
Set objFsoFolder = nothing
Set objFsoWindowsTemp = Nothing
I want to get rid of the On Error Resume next line and test the status of the file if it is locked before removing it.
How can i test for a file lock?