I had a very specific question regarding my code.
So I have a folder. This folder may have> = 0 files. My first script runs in the background, checking if the number of files is> 0. As soon as it is> 0, it activates the second script using the path + file name, and as soon as the file is deleted / deleted from the folder, it displays the file lifetime .
Everything works fine, but there is one problem: If there are several files in a folder in one folder, these are only the "watchers" of the top one (file name, ascending). Therefore, if the first of them is deleted, he probably notices the second, but the lifetime is incorrect, because it did not start until the first was deleted.
Here are my two codes:
Script1.vbs:
Set fso =CreateObject("Scripting.FileSystemObject")
If WScript.Arguments.Count = 1 Then
pfadTiff0 = CStr(WScript.Arguments(0))
Else
msgbox "Bitte Argumente (Pfade) angeben"
WScript.Quit
End If
While True
Set ordnerTiff0 = fso.GetFolder(pfadTiff0)
Set filesTiff0 = ordnerTiff0.Files
anzFilesTiff0 = ordnerTiff0.Files.Count
If anzFilesTiff0 > 0 Then
For Each objFile in filesTiff0
CreateObject("WScript.Shell").Run "QueueTimeUP.vbs " & objFile.Name & " " & pfadTiff0, 0, True
Next
End If
WScript.Sleep 2000
WEnd
Script2.vbs:
filename = CStr(WScript.Arguments(0))
pfad = CStr(WScript.Arguments(1))
Set fso = CreateObject("Scripting.FileSystemObject")
startZeit = Timer()
komplett = pfad&"\"&filename
While fso.FileExists(komplett) = True
WScript.Sleep 100
WEnd
endZeit = Timer()
differenz = endZeit-startZeit
msgbox "Existenz von Job " & filename & " in Sekunden: " & differenz