1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| dim fsoFolder, oFolder, oFiles, oFile
dim output, output_avant
dim directory
dim dodo
dim reveil
dim batchMode
dim date_av
'-----------------------------------------------------------------
'--- Dossier à scruter -------------------------------------------
directory = "C:\xxxxxxx"
'--- Delais de scrutation (en secondes) --------------------------
dodo = 60
'--- Reveil (en minutes) --------------------------
reveil = 180
'--- Mode boucle san fin (1) ou lancement ordonnancé (0)----------
batchmode = 1
'-----------------------------------------------------------------
if batchmode then
while not Go
WScript.Sleep dodo*1000
wend
Else
Go
End if
'-----------------------------------------------------------------
'--- Go
'--- retourne 0 s'il faut sortir 1 sinon
'-----------------------------------------------------------------
Function Go
Set fsoFolder = CreateObject("Scripting.FileSystemObject")
Set oFolder = fsoFolder.GetFolder(directory)
Set oFiles = oFolder.Files
output =""
Go=1
'Liste les fichiers
for each oFile in oFiles
output = output & oFile.Name & vbCrLf
if oFile.Name = "STOP.txt" then
Go=0
end If
next
'Message si on reçoit un fichier (cas de changement)
if output <> "" and output_avant ="" or output <> output_avant and output <> "" then
MsgBox output, 0, "message initial"
End If
'Recupere la date si 1er message
if output <> "" and output_avant ="" then
date_av=now
End if
'Message si attente plus de x minutes
if output_avant <>"" and output = output_avant and DateDiff("n", date_av, now) >= reveil then
MsgBox output, 0, "message relance"
date_av=now
End if
'Enregistrement pour prochaine itération
output_avant=output
End Function |
Partager