| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 
 | Option Explicit
 
Const ForWriting = 2
Dim I, strComputer,objWMIService, colFiles, objFile, Reponse, fso, objFich
 
Reponse = InputBox("Donner l'extension du type de fichier à rechercher :","Extension de fichier", "mp3")
If Reponse = "" then 
   Wscript.Quit 0
Else
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set objFich = fso.OpenTextFile("Resultat.txt", ForWriting, True)
   I = 0
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Extension = '" & Reponse & "'")
For Each objFile in colFiles
    i = i + 1
     objFich.WriteLine "[" & AddZeros(i) &"]  " & objFile.Name 'chemin complet du fichier
Next
End If
MsgBox "Nombre de fichiers trouvés : " & cstr(i)
'==================
Function AddZeros(varIn)
    AddZeros = Right("00000" & CStr(varIn),5)
End Function | 
Partager