Код:

If Not Pult("z:\ops", "dir", 2, "lock", "file.lock", "start.bat", 3600) Then WScript.Echo "Пульты заняты"
'-------------
Function Pult(DirPre, DirRoot, DirNlen, DirSuff, FileLock, FileBat, OldSec)
Pult = False
iii = 10000000
With CreateObject("Scripting.FileSystemObject")
For i = iii To iii + 10 ^ DirNlen - 1
SearchDir = DirRoot + Right(CStr(i), DirNlen)
dFile = DirPre + "\" + SearchDir + "\" + DirSuff
If .FolderExists(dFile) Then
iFile = dFile + "\" + FileLock
If .FileExists(iFile) Then
Pult = DateDiff("s", .GetFile(iFile).DateLastModified, Now) > OldSec
Else
Pult = True
End If
If Pult Then
' MsgBox "cmd.exe /c " + DirPre + "\" + SearchDir + "\" + FileBat
CreateObject("WScript.Shell").Run "cmd.exe /c """ + DirPre + "\" + SearchDir + "\" + FileBat + """, 0, False"
Exit For
End If
End If
Next
End With
End Function