I'd like to kick off a rename of a file as soon as it is written, but I am not sure how to tell when the program has released the lock.
Thanks!
How Can I Tell When a File is no Longer Locked?
Moderators: Dorian (MJT support), JRL
-
- Junior Coder
- Posts: 24
- Joined: Tue Sep 15, 2009 3:20 pm
How Can I Tell When a File is no Longer Locked?
I think I can automate that!
-
- Junior Coder
- Posts: 24
- Joined: Tue Sep 15, 2009 3:20 pm
THis might work if you want to insert a VBA bit.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
MySubje()
Private Sub MySubje()
On Error Resume Next
Dim strFileName
' Full path and name of file.
strFileName = "k:\test.txt"
Set fLog = fso.OpenTextFile(strFileName, ForAppending, True)
If Err.Number = 70 Then
WScript.Echo "locked"
Else
WScript.Echo "not locked"
End If
Err.Clear
End Sub
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
MySubje()
Private Sub MySubje()
On Error Resume Next
Dim strFileName
' Full path and name of file.
strFileName = "k:\test.txt"
Set fLog = fso.OpenTextFile(strFileName, ForAppending, True)
If Err.Number = 70 Then
WScript.Echo "locked"
Else
WScript.Echo "not locked"
End If
Err.Clear
End Sub
I think I can automate that!