' ---------------------------------------------------------- ' Script d'affichage de la liste des programmes lancés au démarrage ' à partir : ' de la BDR (clefs HKCR\...\run et HKLM\...\run ' des menus démarrer\démarrage commun et utilisateur ' ' JC BELLAMY © 2011 ' ---------------------------------------------------------- Const SW_HIDE=0 Const SW_SHOWNORMAL=1 const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 const HKEY_LOCAL_MACHINE = &H80000002 const HKEY_USERS = &H80000003 const HKEY_CURRENT_CONFIG = &H80000005 Const REG_SZ = 1 Const REG_EXPAND_SZ = 2 Const REG_BINARY = 3 Const REG_DWORD = 4 Const REG_MULTI_SZ = 7 ForWriting = 2 Dim shell, fso Set shell = WScript.CreateObject("WScript.Shell") Set net = Wscript.CreateObject("WScript.Network") Set fso = WScript.CreateObject("Scripting.FileSystemObject") Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") S="Liste des programmes lancés au démarrage" S=S & VBCRLF & VBCRLF & "Clef HKCU" S=S & VBCRLF & "---------" EnumKeyrun HKEY_CURRENT_USER S=S & VBCRLF & VBCRLF & "Clef HKLM" S=S & VBCRLF & "---------" EnumKeyrun HKEY_LOCAL_MACHINE S=S & VBCRLF & VBCRLF & "Menu démarrer utilisateur" S=S & VBCRLF & "-------------------------" EnumFolderStart HKEY_CURRENT_USER,"Startup" S=S & VBCRLF & VBCRLF & "Menu démarrer commun" S=S & VBCRLF & "--------------------" EnumFolderStart HKEY_LOCAL_MACHINE,"Common Startup" Set dirtemp = fso.GetSpecialFolder(2) nomtxt = dirtemp & "\Startlist.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 programmes lancés au démarrage 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 '-------------------------------------------------------------------- Sub EnumKeyrun(hk) KeyMain="SOFTWARE\Microsoft\Windows\CurrentVersion\Run" lRC = oReg.EnumValues(hk, KeyMain, sNames, iTypes) For i = LBound(sNames) To UBound(sNames) If trim(sNames(i))<>"" Then S=S & VBCRLF & sNames(i) next End Sub '-------------------------------------------------------------------- Sub EnumFolderStart(hk,valuename) KeyMain="SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" oReg.GetStringValue hk,KeyMain,valuename,Path Set f = fso.GetFolder(path) Set collf=f.Files For each sc in collf Nom=sc.name p=InstrRev(Nom,".") ext="" If p>0 Then ext=mid(Nom,p) If StrComp(ext,".lnk",vbTextCompare)=0 Then S=S & VBCRLF & left(Nom,p-1) Next End Sub