' ---------------------------------------------------------- ' Script d'énumération des dossiers spéciaux du compte en cours ' Syntaxe: EnumSpecialFolders ' ' JC BELLAMY © 2010 ' ---------------------------------------------------------- Const SW_HIDE=0 Const SW_SHOWNORMAL=1 ForWriting = 2 Set net = Wscript.CreateObject("WScript.Network") Set Shell= Wscript.CreateObject("WScript.Shell") Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set fldrs=Shell.SpecialFolders Fname=array( _ "Desktop", _ "AllUsersDeskTop", _ "StartMenu", _ "AllUsersStartMenu", _ "Programs", _ "AllUsersPrograms", _ "StartUp", _ "AllUsersStartup", _ "AppData", _ "Favorites", _ "Fonts", _ "MyDocuments", _ "NetHood", _ "PrintHood", _ "Recent", _ "SendTo", _ "Templates") Comment=array( _ "Bureau", _ "Bureau (commun)", _ "Menu démarrer", _ "Menu démarrer (commun)", _ "Programmes", _ "Programmes (commun)", _ "Démarrage", _ "Démarrage (commun)", _ "Application Data", _ "Favoris", _ "Polices", _ "Mes documents", _ "Voisinage réseau", _ "Voisinage d'impression", _ "Documents récents", _ "Envoyer vers", _ "Modèles") T="Dossiers spéciaux du compte " & net.UserName & " (ordinateur " & net.Computername & ") :" S=String(Len(T),"=") & VBCRLF & T & VBCRLF & String(Len(T),"=") For i = LBound(Fname) To UBound(Fname) S=S & VBCRLF & VBCRLF s=s & Comment(i) & " : " & VBCRLF & " " & fldrs(Trim(Fname(i))) Next REM Wscript.echo s Set dirtemp = fso.GetSpecialFolder(2) nomtxt = dirtemp & "\liste-ds.txt" Set fictxt=fso.OpenTextFile(nomtxt, ForWriting,true) fictxt.WriteLine S fictxt.close computer=net.computername set PrinterSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & Computer).ExecQuery _ ("SELECT * FROM Win32_Printer") DefPrint="imprimante par défaut" for each Printer in PrinterSet Attrib=Cint(Printer.Attributes) If (Attrib and 4)=4 then DefPrint=Printer.Caption exit for end if next prompt="La liste des dossiers spéciaux a été stockée dans" & VBCRLF & _ "le fichier " & nomtxt & VBCRLF & VBCRLF & _ "Appuyer sur :" & VBCRLF & _ " OUI pour l'imprimer sur " & DefPrint & VBCRLF & _ " NON pour l'ouvrir avec le bloc-notes" rep=MsgBox(prompt, vbYesNo + vbQuestion, curdir) If rep=vbYes Then commutateur=" /p " show=SW_HIDE else commutateur=" " show=SW_SHOWNORMAL end if ' Impression ou affichage du fichier à l'aide du bloc-notes commande=shell.ExpandEnvironmentStrings("%windir%\notepad.exe" & commutateur & chr(34) & nomtxt & chr(34)) shell.Run commande, show, true Wscript.quit