Script VBS (envoi de mail si jamais je trouve un message dans plusieurs fichiers à la date du jour)
Bonjour,
Je suis en train de travailler sur un script qui permettrais d'analyser plusieurs fichier (ceux qui ont dans leurs noms date du jour même).
Le mot serait Error puis il y aurais éventuellement un envois de mail si on trouve le mot.
Malheureusement, il me met comme message (ligne non trouvé)
fichier.txt :
this is error
Code:
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
| Const ForReading = 1
Dim strSearchFor
strSearchFor = "error"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("fichier.txt", ForReading)
do until objTextFile.AtEndOfStream
strLine = objTextFile.ReadLine()
If InStr(1, strLine, strSearchFor) <> 0 then
Wscript.Echo "ligne trouvee"
Wscript.Echo strLine
Else
Wscript.Echo "ligne non trouvee"
End If
loop
objTextFile.Close
Option Explicit
DIM fso
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists("fichier.txt")) Then
WScript.Echo("Le fichier a ete trouve !")
WScript.Quit()
Else
WScript.Echo("Le fichier n'a pas ete trouve !")
End If
WScript.Quit() |