GEOSoft Posted March 4, 2009 Share Posted March 4, 2009 Thanks to MS Customer Experience we have another batch of useless files that do nothing except clutter your drive. Namely SQM files. These are Quality Management files created pretty much every time you open any of the later versions of MSN Messenger Live (and probably others). I'm working on a fix to prevent the files even being created but for now this code will remove them. Just add it to whatever file cleanup script you use now. expandcollapse popup_DelSQM(@HomeDrive & "\") If FileExists(@AppDataDir & "\Roaming\Microsoft\MSN Messenger\") Then $sFldrPath = @AppDataDir & "\Roaming\Microsoft\MSN Messenger\" Else $sFldrPath = @AppDataDir & "\Microsoft\MSN Messenger\" EndIf $aFldrs = _FldrListToArray($sFldrPath) If IsArray($aFldrs) Then For $i = 1 To Ubound($aFldrs)-1 If $aFldrs[$i] = $sFldrPath Then ContinueLoop _DelSQM($aFldrs[$i]) Next EndIf Func _DelSQM($sFldr) Local $sSearch = FileFindFirstFile($sFldr & "*.sqm"), $sFound, $sFile If NOT @Error Then While 1 $sFound = FileFindNextFile($sSearch) If @Error Then ExitLoop $sFile = $sFldr & $sFound FileSetAttrib($sFile, "-HRS+N") FileDelete($sFile) WEnd EndIf FileClose($sSearch) EndFunc ;<==> _DelSQM() Func _FldrListToArray($szRoot, $sIgnore = "", $iRecurs = 1 ) If StringRight($szRoot, 1) <> '\' Then $szRoot &= '\' Local $szReturn = '', $szBuffer = '', $szPathlist = '*', $oRoot = $szRoot & '*', $sChk = $szRoot $Hfile = FileFindFirstFile ($szRoot &'*') If $Hfile >= 0 Then $szBuffer = FileFindNextFile ($Hfile) While NOT @Error If Not StringInStr($szBuffer, '.') Then If $sIgnore AND StringRegExp($szBuffer, "(?i)" & $sIgnore) Then $szBuffer = FileFindNextFile ($Hfile) ContinueLoop EndIf If StringInStr($szRoot & $szBuffer, $sChk) Then $szPathlist &= $szRoot & $szBuffer & "\*" EndIf $szBuffer = FileFindNextFile ($Hfile) Wend FileClose ($Hfile) EndIf $szReturn = $szPathList If $iRecurs = 1 Then $szPathList = StringTrimLeft($szPathlist, 1) $szRoot = StringLeft($szPathList, StringInStr($szPathlist, '*') -1) While 1 $hFile = FileFindFirstFile ($szRoot & '*') If $hFile >= 0 Then $szBuffer = FileFindNextFile ($Hfile) While NOT @Error If Not StringInStr($szBuffer, '.') Then If NOT $sIgnore Then If StringInStr($szRoot & $szBuffer, $sChk) Then $szPathlist &= $szRoot & $szBuffer & "\*" If StringInStr($szRoot & $szBuffer, $sChk) Then $szReturn &= $szRoot & $szBuffer & "\*" Else If NOT StringRegExp($szBuffer, "(?i)" & $sIgnore) Then If StringInStr($szRoot & $szBuffer, $sChk) Then $szPathlist &= $szRoot & $szBuffer & "\*" If StringInStr($szRoot & $szBuffer, $sChk) Then $szReturn &= $szRoot & $szBuffer & "\*" EndIf EndIf EndIf $szBuffer = FileFindNextFile ($Hfile) Wend FileClose($hFile) $szPathList = StringReplace($szPathList, $szRoot, '') EndIf If $szPathList == '*' Then ExitLoop $szPathlist = StringTrimLeft ($szPathlist, 1) $szRoot = StringLeft ($szPathlist, StringInStr ($szPathlist, "*") - 1) & "\" $szPathlist = StringTrimLeft ($szPathlist, StringInStr ($szPathlist, "*") - 1) Wend EndIf If StringLeft($szReturn, 1) = '*' Then $szReturn = StringTrimLeft($szReturn, 1) $szReturn = StringReplace($szReturn, '\\', '\') If StringRight($szReturn, 1) = '*' Then $szReturn = StringTrimRight($szReturn,1) $szReturn = StringSplit($oRoot & $szReturn,'*') If $szReturn = '*' or $szReturn = '' Then Return 0 Return $szReturn EndFunc ;<==> _FldrListToArray() I'm only checking the 3 folders that I'm aware of, so if you find these files in other locations then please let us know. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now