Au Fil du Temps


Accueil
'----------------------------------------------- GETTASKRUN--------------------------------------------'
'-- DESCRIPTION : 
'--	- Enumération des entrées situées sous HKLM\Software\Microsoft\CurrentVersion\Run
'--     - Option de suppression d'une clé via une page web.
'--     - Un fichier temporaire "GetTaskRun.tmp.html" est crée dans le répertoire %TEMP% de l'utilisateur
'--	  puis supprimer. EXECUTER CE SCRIPT AVEC LES DROITS SUFFISANTS.
'-- ENTREE : -
'-- SORTIE :  liste des programmes éxécutés à l'ouverture de session.
'---------------------------------------------------------------------------------------------------------'

On error resume next

Dim objWSH
Dim objFSO
Dim objEnvUser
Dim FILETEMP		' Fichier temporaire
Dim HOMEFILETEMP
Dim strcmd
Dim strKey		' Clé de registre à lister' strKey comme chaîne de recherche dans FILETEMP
Dim i

set objWSH = Wscript.CreateObject("wscript.shell")
set objFSO = Wscript.CreateObject("scripting.FileSystemObject")
StrKey =  "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
strKeyRun =  "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]"

'-------------------------------------------------
' Création du fichier temporaire "gettaskrun.tmp"
'-------------------------------------------------

set objEnvUser  = objWSH.Environment("USER")
FILETEMP = objWSH.ExpandEnvironmentStrings(objEnvUser("TEMP")) &  "\gettaskrun.tmp.html"	
HOMEFILETEMP = """" & objWSH.ExpandEnvironmentStrings(objEnvUser("TEMP")) & "\gettaskrun.tmp.html" & """"
strcmd = "cmd /c start /B /HIGH regedit /E " & HOMEFILETEMP & "  " & """" &  strKey & """"  
objWSH.Run strcmd,0,True	'Masque la fenêtre et attente de l'éxécution de la commande 
set objEnvUser = Nothing
Wscript.Sleep 500


' COMMENTAIRE:
' La variable environnement TEMP est bien celle qui est définit dans le répertoire privé
' Voir les propriétés systèmes / Avancé / Variables environnement
' TEMP est sous la forme d'une variable de substitution,la méthode ExpandEnvironmentStrings
' permet d'étendre le chemin.

'------------------------------------------------- ' Récupération des clés '------------------------------------------------- Dim aProgRun() Dim strProg Dim objFile Set objFile = objFSO.OpenTextFile(FILETEMP,1,false,-1) 'Fichier unicode en lecture seule i = 0 Do While objFile.AtEndOfStream <> True strProg = objFile.ReadLine if(strProg = strKeyRun ) Then strProg = objFile.readLine if(strProg = "") Then msgbox strKeyRun & vbcrlf & vbCrlf & vbtab & vbTab & " !!! Aucun élément !!! " Wscript.Quit End if do i = i + 1 aProgRunTmp = Split(strProg, "=", -1, 1) redim preserve aProgRun(i) aProgRun(i) = mid(aProgRunTmp(0),2,len(aProgRunTmp(0))-2 ) i = i + 1 redim preserve aProgRun(i) aProgRun(i) = mid(aProgRunTmp(1),2,len(aProgRunTmp(1))-2) strProg = objFile.readLine Loop while(strProg <> "") exit Do End if Loop objFile.close set objFile= Nothing



' COMMENTAIRE:
' Comme aucune fonction n'existe sous WSH pour obtenir un point d'ancrage pour parcourir l'arborescence de
' la base de registre, une alternative est d'exporter une branche à l'aide de REGEDIT.EXE.
' Il convient pour l'ouverture du fichier exporté d'employer les options adéquates.
' Seule la branche voulue est traité,l'EXIT DO sort de la boucle.On extrait à l'occasion les guillemets pour
' la paire NAME/VALUE.



'------------------------------------------------------- ' Traitement des données en HTML '------------------------------------------------------
Dim strSCRIPT strSCRIPT = "<script id=clientEventHandlersVBS language=vbscript>" & vbCrLF & _ " Sub btnSuppr_onclick " & vbCrLF & _ " Dim objSH " & vbCrLF & _ " Dim progname" & vbCrLF & _ " Dim i" & vbCrLF & _ " Dim blnchecked" & vbCrLF & _ " Dim strValid " & vbCrLF & _ " strValid = Msgbox(""Si une ou plusieurs clés ont été cochées la suppression sera définitive ?"",vbOKCancel + vbDefaultButton2,""Base de registre"")" & vbCrLF & _ " if(strValid = vbCancel) Then " & vbCrLF & _ " for i=1 to T1.rows.length " & vbCrLF & _ " execute(""blnchecked = checkbox"" & i & "".checked"")" & vbCrLF & _ " if(blnchecked = true ) Then" & vbCrLF & _ " execute(""checkbox"" & i & "".checked="" & """"""false"""""")" & vbCrLF & _ " end if " & vbCrLF & _ " next" & vbCrLF & _ " exit sub" & vbCrLF & _ " End if" & vbCrLF & _ " set objSH= CreateObject(""WScript.Shell"")" & vbCrLF & _ " for i=1 to T1.rows.length " & vbCrLF & _ " execute(""blnchecked = checkbox"" & i & "".checked"")" & vbCrLF & _ " if(blnchecked = true) Then "& vbCrLF & _ " execute(""progname = "" & ""namepgrun"" & i & "".innerHTML"") " & vbCrLF & _ " objSH.RegDelete(""" & strKey & "\" & """ & progname) " & vbCrLF & _ " execute(""checkbox"" & i & "".style.visibility ="" & """"""hidden"""""") " & vbCrLF & _ " execute(""checkbox"" & i & "".checked="" & """"""false"""""")" & vbCrLF & _ " execute(""namepgrun"" & i & "".style.textDecoration="" & """"""line-through"""""") " & vbCrLF & _ " execute(""parampgrun"" & i & "".style.textDecoration="" & """"""line-through"""""") " & vbCrLF & _ " execute(""namepgrun"" & i & "".style.backgroundColor="" & """"""gold"""""") " & vbCrLF & _ " execute(""parampgrun"" & i & "".style.backgroundColor="" & """"""gold"""""") " & vbCrLF & _ " end if" & vbCrLF & _ " next " & vbCrLF & _ " End Sub" & vbCrLF & _ " Sub btnFermer_onclick" & vbCrLF & _ " window.close() " & vbCrLF & _ " End Sub" & vbCrLF & _ "</SCRIPT>" & vbCrLF Dim strTable,strTableDebut Dim strTableName,strTableFin Dim strWarning Dim strBUTTON dim indice strWarning = "<H3><FONT style=""COLOR: lightseagreen"">" & strKEY & "</FONT></H3><BR><BR>" & vbCrLf & _ " Attention: Ce script est valable uniquement pour cette branche " & vbCrlf strTableName = "<TABLE width=700 cellSpacing=1 cellPadding=1 align=left border=1 style='HEIGHT: 30px' height=30>" & vbCrLf &_ " <TR><TD width=250><DIV align=center style=""width:250"">NOM</DIV></TD> " & vbCrlf & _ " <TD width=450><DIV align=center>VALEUR</DIV></TD></TR></TABLE>" strBUTTON = "<INPUT id=btnSuppr style='COLOR: white; BACKGROUND-COLOR: black' type=button value=Supprimer> " & vbCrLf & _ "<INPUT id=btnFermer style='COLOR: white; BACKGROUND-COLOR: black' type=button value=Fermer >" & vbCrlf strTableDebut = "<P><TABLE id=T1 cellSpacing=1 cellPadding=1 width=700 align=left border=1 style='HEIGHT: 30px' height=30>" & vbCrLf strTableFin = "</TABLE></DIV></P>" & vbCrLf strTable = strTableDebut indice = 1 for i = 1 to ubound(aProgRun) step 2 strTable = strTable & " <TR> " & vbCrlf & _ " <TD id=namepgrun" & indice & " width=250>" & aProgRun(i) & "</TD>" & vbcrlf & _ " <TD id=parampgrun" & indice & " width=400>" & aProgRun(i + 1) & "</TD>" & vbCrLf & _ " <TD width=30><INPUT type='checkbox' id=checkbox" & indice & " name=checkbox" & indice & "></TD>" & vbCrLf & _ " </TR>" & vbCrLf indice = indice + 1 next strTable = strTable & strTableFin '----------------------------------------------------- ' Supression du fichier temporaire '----------------------------------------------------- If(objFSO.FileExists(FILETEMP) = True) then valret = objFSO.DeleteFile(FILETEMP,true) End if '----------------------------------------------------- ' Affichage du résultat avec - Internet Explorer - 2 OPTIONS '----------------------------------------------------- '------------------------ Windows 2000 [ Option 1 DEBUT] -------------------- 'set oIE = Wscript.CreateObject("InternetExplorer.Application") 'oIE.navigate("") 'oIE.document.writeln(strSCRIPT) 'oIE.document.writeln(strWarning) 'oIE.document.writeln("<BR><BR>") 'oIE.document.writeln(strTableName) 'oIE.document.writeln("<BR><BR>") 'oIE.document.writeln(strTable) 'oIE.document.writeln(strBUTTON) 'oIE.visible = true 'oIE.document.title = "- Au fil du Temps - Clés de registre" 'objWSH.AppActivate oIE.document.title '--------------------------------------[ Option 1 FIN] ---------------------- '----------------------- Pour Windows 2000 / XP [ OPTION 2 DEBUT] ---------------------------------- ' Pour Windows XP la création d'objet (ex:WScript.Shell) à l'éxécution ne s'effectue pas (Bug ???) ' et le gestionnaire d'évènement réagit autrement. ' Le code sera copié dans le fichier temporaire et executé '---------------------------------------------------------------------------------------------- Set objFile = objFSO.OpenTextFile(FILETEMP,2,true,0) objFile.WriteLine strSCRIPT objFile.WriteLine strWarning objFile.WriteLine "<BR><BR>" objFile.WriteLine strTableName objFile.WriteLine "<BR><BR>" objFile.WriteLine strTable objFile.WriteLine strBUTTON objFile.close Wscript.Sleep 500 set oIE = Wscript.CreateObject("InternetExplorer.Application") FILETEMPIE = Replace(FILETEMP,"\\","/") oIE.navigate("file:///" & FILETEMPIE) oIE.document.title = "- Au fil du Temps - Clés de registre" oIE.visible = true objWSH.AppActivate oIE.document.title while(oIE.visible) ' En attente que la fenêtre soit fermé et suppression du fichier Wend If(objFSO.FileExists(FILETEMP) = True) then valret = objFSO.DeleteFile(FILETEMP,true) End if '----------------------- [ OPTION 2 FIN ] ----------------------------------
'----------------------------------------------------- 'Fermeture des variables objets '----------------------------------------------------- set objFSO = Nothing set objWSH = Nothing Wscript.Quit
Téléchargez GetTaskRun.vbs