'=========================== 'list_authorized_folders.vbs 'parcourir les sous-dossiers de premier niveau 'et savoir si l'on y a accès 'utile quand le nb de sous-dossiers est grand '=========================== Option Explicit Dim oFSO, d Set oFSO = CreateObject("Scripting.FileSystemObject") CommandLine Sub CommandLine If Wscript.Arguments.Count=0 Then Syntaxe Else d = Wscript.Arguments(0) If oFSO.FolderExists(d) Then ScanFolder d Else Wscript.Echo "Le dossier " & d & " n'existe pas." End If End If End Sub Sub ScanFolder(d) '========== 'browse folder d '========== Dim f, tmp, a, b, c, nbErr, da On Error Resume Next Wscript.Echo String(Len("Sous-dossiers de " & d)+4,"*") & vbcrlf & _ "* Sous-dossiers de " & d & " *" & vbcrlf & _ String(Len("Sous-dossiers de " & d)+4,"*") For Each f in oFSO.GetFolder(d).Subfolders Set tmp=f.Subfolders a=tmp.count 'l'erreur se produit ici si accès refusé If Err Then b = " " c = " (" & Err.Description & ")" nbErr=nbErr+1 err.Clear da = da & b & f.Name & c & vbcrlf Else b=" " c="" Wscript.Echo b & f.Name & c End If Next Wscript.Echo vbcrlf & _ nbErr & " dossiers inaccessibles : " & vbcrlf & da End Sub Sub Syntaxe Wscript.Echo "Entrer un dossier valide sur la ligne de commande." End Sub