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
| Dim Commande, MsG, RecupLg, RecupCl, T, WshShell, oFso, f
Const ForReading = 1
Set WshShell = CreateObject("WScript.Shell")
Commande = " /c Dir c:\p* > c:\Frecup.txt" ' /c Exécute la commande donnée par la chaîne de caractères puis se termine.
WshShell.Run "cmd.exe" & Commande, vbHide
Set WshShell = NotHing
WScript.Sleep 100
Set oFso = CreateObject("Scripting.FileSystemObject")
Set f = oFso.OpenTextFile("c:\Frecup.txt", ForReading)
MsG = f.ReadAll
f.Close
oFso.DeleteFile "c:\Frecup.txt",True ' Le paramétre "Force" à true permet d'effacer les fichiers en lectures seules.
Set oFso = NotHing
RecupLg = Split(MsG, vbCrLf)
MsG = ""
For T = 0 To UBound(RecupLg) - 1
RecupCl = Split(RecupLg(T), "<REP>", -1, vbTextCompare)
If UBound(RecupCl) >= 1 Then MsG = MsG & vbCrLf & Trim(RecupCl(1))
Next
If MsG <> "" Then
MsgBox MsG, vbInformation, "Ok"
Else
MsgBox "Pas de repertoire de trouvé", vbCritical, "Ko"
End If |
Partager