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
| Option Explicit
Dim Titre,fso,ws,NewLogFile,Resultat
Titre = "Découpage de Chaînes"
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("Wscript.Shell")
'Nom du fichier qui va stocker le résultat
NewLogFile = Left(Wscript.ScriptFullName,InstrRev(Wscript.ScriptFullName, ".")) & "txt"
if fso.FileExists(NewLogFile) Then 'Si le fichier LogFile existe
fso.DeleteFile NewLogFile 'alors on le supprime
end If
MsgBox LireLogFile("Dhcp.log"),64,Titre
Call WriteNewLogFile(LireLogFile("Dhcp.log"),NewLogFile)
Resultat = ws.Run(NewLogFile,1,False)
'**************************************************************************************
Function LireLogFile(TextFile)
Dim Msg,MyTab
Msg = ""
With CreateObject("Scripting.FileSystemObject").OpenTextFile(TextFile)
While .AtEndOfStream = False
LireLogFile = .ReadLine
LireLogFile = Replace(LireLogFile,"- ","*")
LireLogFile = Replace(LireLogFile," -","*")
LireLogFile = Replace(LireLogFile,"D-","*")
MyTab = Split(LireLogFile,"*")
Msg = Msg & "@IP = " & MyTab(0) & vbCrLf & "@Mask = " & MyTab(1) & vbCrLf &_
"@MAC = " & MyTab(2) & vbCrLf & "Date = " & MyTab(3) & vbCrLf & MyTab(4) & vbCrLf & "Domaine = " & MyTab(5) & vbCrLf & String(40,"*") & vbCrLf
Wend
End With
LireLogFile = Msg
End Function
'*****************************************************************
'Fonction pour écrire le résultat dans un nouveau fichier texte
Sub WriteNewLogFile(strText,NewLogFile)
Dim fs,ts
Const ForAppending = 8
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(NewLogFile,ForAppending,True)
ts.WriteLine strText
ts.Close
End Sub
'***************************************************************** |
Partager