' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Const ForAppending = 8 

On Error Resume Next 

fnm = WScript.Arguments(0)

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(fnm, ForAppending)
If Err.Number = 0 Then
    WScript.Echo fnm & " locked"
    WScript.StdOut.Write "Press any key to continue"
    WScript.StdIn.Read(1)
    WScript.Echo fnm & " unlocked"
    f.Close
Else
    WScript.Echo fnm & " locking failed"
End If
Set f = Nothing
Set fso = Nothing
