Lecture de la clé HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
Le résultat via un fichier temporaire est interprété en HTML avec une option de suppression.
PS: Exécuter le script avec des droits administratifs. Le code ne fonctionne qu'avec Internet Explorer
Source / Exemple :
'----------------------------------------------- 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.
'-- ENTREE : -
'-- SORTIE : liste des programmes éxécutés à l'ouverture de session.
'--------------------------------------------------------------------------------------------------------'
'
On error resume next
Dim objWSH
Dim objFSO
Dim objEnvUser
Dim FILETEMP
Dim HOMEFILETEMP
Dim strcmd
Dim strKey
Dim strKeyRun
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]"
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
set objEnvUser = Nothing
Wscript.Sleep 500
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
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
If(objFSO.FileExists(FILETEMP) = True) then
valret = objFSO.DeleteFile(FILETEMP,true)
End if
'------------------------ Windows 2000 ------------------------
'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
'---------------------------------------------------------------
'----------------------- Windows 2000 / XP ----------------------------------------------------
' 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é
Wend
If(objFSO.FileExists(FILETEMP) = True) then
valret = objFSO.DeleteFile(FILETEMP,true)
End if
set objFSO = Nothing
set objWSH = Nothing
Wscript.Quit
Conclusion :
Ce script est aussi disponible sur mon site
http://www.aufildutemps.info
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.