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
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
XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE)[HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE) par Gio
Je m'y prends un peu tard je sais, mais bon je suis développeur web et donc hyper fainéant ! Toujours dans le cadre des technologies émergentes, ici HTML5, parce qu'on aime HTML5 chez Wyg , nous seront présent, le vieux ( Aurélien V.) et moi, pour pr...
Cliquez pour lire la suite de l'article par Gio [WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|