Accueil > > > VIDER LES DOSSIERS TEMP ET RECENT
VIDER LES DOSSIERS TEMP ET RECENT
Information sur la source
Description
Les répertoires "Recent" et "Temp" contiennent des fichiers, des dossiers et/ou des raccourcis vers les fichiers ou dossiers ouverts (programmes ou autres). A mesure qu'on travaille, la taille de ces dossiers augmente jusqu'à devenir encombrante. les fichiers et dossiers dans ces deux répertoires sont en fait superflus et ne servent pratiquement à rien. Cet outil, sous forme de console, peut les vider à chaque démarrage de Windows. Mais l'ennuie est que certains programmes d'installation laissent des fichiers dans le répertoire "Temp" qui seront utilisés pour la finalisation après un redémarrage demandé par l'installation. Dans un tel cas de figure, on doit supprimer l'entrée créée dans la base du registre relative au lancement de l'outil "DeletAtStartup.exe". Cette clé est la suivante: HKLM\Software\Microsoft\Windows\CurrentV ersion\RunServices\DeletAtStartup.exe ATTENTION : SUPPRIMER UNIQUEMENT LA VALEUR "DeletAtStartup.exe"
Source
- Option Explicit
-
- Type OSVERSIONINFO
- dwOSVersionInfoSize As Long
- dwMajorVersion As Long
- dwMinorVersion As Long
- dwBuildNumber As Long
- dwPlatformId As Long
- szCSDVersion As String * 128
- End Type
- Type SHITEMID
- cb As Long
- abID As Byte
- End Type
- Type ITEMIDLIST
- mSID As SHITEMID
- End Type
- Const CSIDL_RECENT = &H8
- Const NOERROR = &H0
- Const VER_PLATFORM_WIN32_NT = 2
-
- Dim Obj As Object
- 'Const Key1 = "HKCU\Software\Microsoft\Windows\CurrentVersion\"
- Const Key = "HKLM\Software\Microsoft\Windows\CurrentVersion\"
-
- Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
- Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
- Private Declare Function FindWindow Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
- Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
- Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long
- Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
- Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
- Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
- Private Declare Function ShowWindow Lib "USER32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
- Private Declare Function PostMessage Lib "USER32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
-
- Dim FSO As New FileSystemObject, FF&
- Const WM_CLOSE = &H10
- Const SW_SHOWMINNOACTIVE = 7
- Private Function GetSpecialfolder(CSIDL As Long) As String
- Dim Ret&
- Dim IDL As ITEMIDLIST, Path$
- ' Retourne un dossier (SpecialFolder)
- Ret = SHGetSpecialFolderLocation(100, CSIDL, IDL)
- If Ret = NOERROR Then
- 'Crée un tempon
- Path$ = Space$(512)
- ' Retourne un chemin à partir de IDList
- Ret = SHGetPathFromIDList(ByVal IDL.mSID.cb, ByVal Path$)
- ' Supprime les espaces de fin
- GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
- Exit Function
- End If
- GetSpecialfolder = ""
- End Function
-
- Private Function IsWinNT() As Boolean
- Dim ThisOS As OSVERSIONINFO
- ThisOS.dwOSVersionInfoSize = Len(ThisOS)
- GetVersionEx ThisOS
- IsWinNT = (ThisOS.dwPlatformId = VER_PLATFORM_WIN32_NT)
- End Function
- Private Function batFile() As String
- batFile = IIf(Right(App.Path, 1) = "\", App.Path + "DelTmp.bat", App.Path + "\DelTmp.bat")
- End Function
- Private Function GetShortPath(strFileName As String) As String
-
- Dim lngRes As Long, strPath As String
- ' Crée un tempon
- strPath = String$(165, 0)
- ' Retourne le nom court du chemin
- lngRes = GetShortPathName(strFileName, strPath, 164)
- ' Supprime les espaces de fin
- GetShortPath = Left$(strPath, lngRes)
- End Function
- Private Sub CloseThisWindow(Ret As String)
- Dim WinWnd&
- ' Recherche la fenêtre
- WinWnd = FindWindow(vbNullString, Ret)
- If WinWnd = 0 Then MsgBox "Ne peut trouver la fenêtre ...": Exit Sub
- ' Affiche la fenêtre
- ShowWindow WinWnd, SW_SHOWMINNOACTIVE 'SW_SHOWNORMAL
- PostMessage WinWnd, WM_CLOSE, 0&, 0&
- End Sub
- Private Sub WaitToClose()
- Dim OK As Boolean
- OK = False
- Do
- OK = FindWindow(vbNullString, "Terminé - DelTmp")
- DoEvents
- Loop Until OK
- If OK Then
- CloseThisWindow ("Terminé - DelTmp")
- Sleep 500
- DeleteFile batFile
- End If
- End Sub
- Private Sub EcritFich(Optional OK1 As Integer = False, Optional OK2 As Integer = False)
- Dim sPath As String, strSave As String
-
- Dim strTemp As String
- ' Crée une chaîne tempon
- strTemp = String(100, Chr$(0))
- ' Retourne le chemin temporaire
- GetTempPath 100, strTemp
- ' Nettoyage du tempon des espaces indésirables
- strTemp = Left$(strTemp, InStr(strTemp, Chr$(0)) - 1)
-
- strSave = String(200, Chr$(0))
- ' Retourne le chemin du dossier Windows
- sPath = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave)))
- FF = FreeFile
- ' Ecrit des données dans un fichier de commandes qui _
- sera exécuté par la suite.
- ' "Nul" est ajouté pour éviter l'ffichage de la liste _
- des fichiers ou dossiers supprimés
- Open batFile For Output As #FF
- Print #FF, "@Echo ON"
- If OK1 Then
- Print #FF, "@DelTree /Y " + GetShortPath(strTemp) + "* > Nul"
- End If
- If Not IsWinNT Then
- If OK2 Then
- Print #FF, "@DelTree /Y " + sPath + "\Recent\* > Nul"
- End If
- Else
- If OK2 Then
- Print #FF, "@DelTree /Y " & GetShortPath(GetSpecialfolder(CSIDL_RECENT)) + "\* > Nul"
- End If
- End If
- Close #FF
- End Sub
- Public Sub Main()
- Dim Fold$, AppName$, Apath$
-
- AppName = UCase(App.EXEName) + ".EXE"
- ' S'assure que le chemin se termine par "\"
- Apath = IIf(Right(App.Path, 1) = "\", UCase(App.Path), UCase(App.Path) + "\")
- ' Crée un objet pour accéder au registre et crée une _
- entrée pour le lancement du programme au démarrage _
- de WINDOWS
- Set Obj = CreateObject("Wscript.Shell")
- With Obj
- .RegWrite Key & "RunServices\" & AppName, Apath & AppName
- End With
- Call EcritFich(True, True)
- Fold = GetSpecialfolder(CSIDL_RECENT)
- Shell batFile, vbHide
- Call WaitToClose
- End Sub
Option Explicit
Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Type SHITEMID
cb As Long
abID As Byte
End Type
Type ITEMIDLIST
mSID As SHITEMID
End Type
Const CSIDL_RECENT = &H8
Const NOERROR = &H0
Const VER_PLATFORM_WIN32_NT = 2
Dim Obj As Object
'Const Key1 = "HKCU\Software\Microsoft\Windows\CurrentVersion\"
Const Key = "HKLM\Software\Microsoft\Windows\CurrentVersion\"
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
Private Declare Function FindWindow Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function ShowWindow Lib "USER32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function PostMessage Lib "USER32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Dim FSO As New FileSystemObject, FF&
Const WM_CLOSE = &H10
Const SW_SHOWMINNOACTIVE = 7
Private Function GetSpecialfolder(CSIDL As Long) As String
Dim Ret&
Dim IDL As ITEMIDLIST, Path$
' Retourne un dossier (SpecialFolder)
Ret = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If Ret = NOERROR Then
'Crée un tempon
Path$ = Space$(512)
' Retourne un chemin à partir de IDList
Ret = SHGetPathFromIDList(ByVal IDL.mSID.cb, ByVal Path$)
' Supprime les espaces de fin
GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
Exit Function
End If
GetSpecialfolder = ""
End Function
Private Function IsWinNT() As Boolean
Dim ThisOS As OSVERSIONINFO
ThisOS.dwOSVersionInfoSize = Len(ThisOS)
GetVersionEx ThisOS
IsWinNT = (ThisOS.dwPlatformId = VER_PLATFORM_WIN32_NT)
End Function
Private Function batFile() As String
batFile = IIf(Right(App.Path, 1) = "\", App.Path + "DelTmp.bat", App.Path + "\DelTmp.bat")
End Function
Private Function GetShortPath(strFileName As String) As String
Dim lngRes As Long, strPath As String
' Crée un tempon
strPath = String$(165, 0)
' Retourne le nom court du chemin
lngRes = GetShortPathName(strFileName, strPath, 164)
' Supprime les espaces de fin
GetShortPath = Left$(strPath, lngRes)
End Function
Private Sub CloseThisWindow(Ret As String)
Dim WinWnd&
' Recherche la fenêtre
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Ne peut trouver la fenêtre ...": Exit Sub
' Affiche la fenêtre
ShowWindow WinWnd, SW_SHOWMINNOACTIVE 'SW_SHOWNORMAL
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub
Private Sub WaitToClose()
Dim OK As Boolean
OK = False
Do
OK = FindWindow(vbNullString, "Terminé - DelTmp")
DoEvents
Loop Until OK
If OK Then
CloseThisWindow ("Terminé - DelTmp")
Sleep 500
DeleteFile batFile
End If
End Sub
Private Sub EcritFich(Optional OK1 As Integer = False, Optional OK2 As Integer = False)
Dim sPath As String, strSave As String
Dim strTemp As String
' Crée une chaîne tempon
strTemp = String(100, Chr$(0))
' Retourne le chemin temporaire
GetTempPath 100, strTemp
' Nettoyage du tempon des espaces indésirables
strTemp = Left$(strTemp, InStr(strTemp, Chr$(0)) - 1)
strSave = String(200, Chr$(0))
' Retourne le chemin du dossier Windows
sPath = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave)))
FF = FreeFile
' Ecrit des données dans un fichier de commandes qui _
sera exécuté par la suite.
' "Nul" est ajouté pour éviter l'ffichage de la liste _
des fichiers ou dossiers supprimés
Open batFile For Output As #FF
Print #FF, "@Echo ON"
If OK1 Then
Print #FF, "@DelTree /Y " + GetShortPath(strTemp) + "* > Nul"
End If
If Not IsWinNT Then
If OK2 Then
Print #FF, "@DelTree /Y " + sPath + "\Recent\* > Nul"
End If
Else
If OK2 Then
Print #FF, "@DelTree /Y " & GetShortPath(GetSpecialfolder(CSIDL_RECENT)) + "\* > Nul"
End If
End If
Close #FF
End Sub
Public Sub Main()
Dim Fold$, AppName$, Apath$
AppName = UCase(App.EXEName) + ".EXE"
' S'assure que le chemin se termine par "\"
Apath = IIf(Right(App.Path, 1) = "\", UCase(App.Path), UCase(App.Path) + "\")
' Crée un objet pour accéder au registre et crée une _
entrée pour le lancement du programme au démarrage _
de WINDOWS
Set Obj = CreateObject("Wscript.Shell")
With Obj
.RegWrite Key & "RunServices\" & AppName, Apath & AppName
End With
Call EcritFich(True, True)
Fold = GetSpecialfolder(CSIDL_RECENT)
Shell batFile, vbHide
Call WaitToClose
End Sub
Conclusion
Trop de dossiers et fichiers inutiles sont gênant pour un antivirus pendant l'analyse et même pour le système. Cet outil débarrasse l'utilisateur de ces superflus et fait le travail à sa place.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Nettoyage base de registre [ par xavier77 ]
salut à tous, J'ai créer plusieurs Dll en VB6. Apres chaque compilation, j'utilisait Regsvr32 pur les enregistrer... et normalement avant j'
Nettoyage des sources inutiles [ par violent_ken ]
Violent Ken Salut à tous.Ce message s'adresse aux admins de vbfrance.com :Serait-il possible d'enlever définitivement du site les sources d&
Nettoyage de chaine de caractéres [ par FrostByte ]
Bonjour, J'ai une chaine de caractére récupérée via la base de registre, jusque là pas de soucis, le seul probléme actuellement c'est que ma chaine r
Sauvegarder la base de registre. [ par MoiDebutantVB ]
Salut !Dans le cadre d'une appli relative au registre, je me demande comment faire pour sauvegarder la base de registre avant de faire des modifs... S
Modifier une valeur dans la base de registre [ par Asaiel ]
Bonjour,Une petite kestion toute simple:G fait une appli qui utilise la base de registre, et je dois pour cela modifier la valeur d'une clé nomm&
Base de registre ou ini????? [ par Youpien ]
Salut,bon je programme pas depuis longtemps en VB, mais je me posais une question :Je suis en train de faire une application assez grosse en ressource
Lire dans la base de registre via une BDD Access 2002 [ par Asaiel ]
Bonjour, Une petite question toute bete, je souhaite lire une valeur du registre dans mon appli ACCESS. J'utilise le code suivant: Private Sub Form_
Access 2002 et base de registre [ par Asaiel ]
Bonjour, Une petite question toute bete, je souhaite lire une valeur du registre dans mon appli ACCESS 2002. J'utilise le code suivant: Dim key As
Fonction Recherche dans le Registre [ par psgman37 ]
bonjour j'aimerai faire un exe et dedans testé si dans le registre il y a certains patch de securité IE en gros je voudrais pouvoir executer la foncti
Procédures d'interfaçage du registre avec VB6 [ par bouazza92 ]
Bonjour les programmaeurs , je voulais faire un programme qui optimise le pc par quelques modifications du registre avec Visual Basic 6 , pourriez vou
|
Derniers Blogs
TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|