Nunos Posted December 2, 2018 Share Posted December 2, 2018 #include <Array.au3> #include <MsgBoxConstants.au3> Global $aFiles[66] = ["zoek.exe", "zoekscript.txt", "FRST.exe", "FRST64.exe", "Addition.txt", "FRST.txt", "fixlog.txt", "esetsmartinstaller_enu.exe", "AdwCleaner.exe", "dds.com", "dds.txt", "dds.scr", "attach.txt", "rkill.exe", "rkill.com", "rkill.scr", "rkill.txt", "SecurityCheck.exe ", "RGSA.exe", "SAlog.txt", "CKScanner.exe", "CKFiles.txt", "OTL.exe", "OTL.com", "OTL.scr", "OTL.txt", "Extras.txt", "OTS.exe", "OTS.txt", "OTA.exe", "OTA.txt", "RSIT.exe", "RSITx64.exe", "OTC.exe", "Smitfraudfix.exe", "aswMBR.exe", "MBR.exe", "mbr.log", "tdsskiller.exe", "Flash_Disinfector.exe", "avenger.zip", "avenger.exe", "ComboFix.exe", "MiniToolBox.exe", "MTB.txt", "FSS.exe", "FSS.txt", "ExeFix.scr", "ExeFix.com", "ExeFix.bat", "ExeFix.cmd", "ExeFix.pif", "DeFogger.exe", "sc-cleaner.exe", "RogueKillerCMD.exe", "TFC.exe", "TFC.txt", "HijackThis.exe", "HijackThis.log", "MbrScan.exe", "Unhide.exe", "F-SecureOnlineScanner.exe", "SystemLook.exe", "SystemLook_x64.exe", "SystemLook.txt", "RestoreBFE.exe"] RMRemnants() Func RMRemnants() For $i = 0 To (UBound($aFiles) - 1) _RMFile(@UserProfileDir & "\" & $aFiles[$i]) Next EndFunc ;==>RMRemnants Func _RMFile($sFile) If Not FileExists($sFile) Then Return If FileDelete($sFile) Then ;_log($sFile & " was removed.") MsgBox(0, "Success", $sFile & " was removed.") Else ;_log("*** Delete Failed for the file = " & $sFile) MsgBox(0, "Failure", $sFile & " was not removed.") EndIf EndFunc ;==>_RMFile I made the above and then I created three text files that are in the $aFiles array but when I run my script I get output in the console that says RC: 0 but none of my files are deleted. What am I doing wrong? Link to comment Share on other sites More sharing options...
water Posted December 2, 2018 Share Posted December 2, 2018 You have verified that all files exist in the @UserProfileDir directory? Did you verify that @UserProfileDir is exact the directory you think it is (Folder Redirection comes to my mind). My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Nunos Posted December 2, 2018 Author Share Posted December 2, 2018 Not all of the files exist but I did make three of the txt files on my desktop for testing purposes. I don't use any folder redirection that I know of. Link to comment Share on other sites More sharing options...
water Posted December 2, 2018 Share Posted December 2, 2018 You create the files on your desktop (macro @DesktopDir is used to access this directory). But in your script you check @UserProfileDir. This are two different animals My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Nunos Posted December 2, 2018 Author Share Posted December 2, 2018 (edited) I guess I thought the desktop directory was in the user profile. So I won't know where the files are for absolute sure in the user's profile as some guests may download to their desktop others to my documents or downloads folder. What would you suggest to scan the user profile and all of those sub directories for the files in that array? EDIT: expandcollapse popup#include <Array.au3> #include <MsgBoxConstants.au3> #include <File.au3> Global $aFiles[66] = ["zoek.exe", "zoekscript.txt", "FRST.exe", "FRST64.exe", "Addition.txt", "FRST.txt", "fixlog.txt", "esetsmartinstaller_enu.exe", "AdwCleaner.exe", "dds.com", "dds.txt", "dds.scr", "attach.txt", "rkill.exe", "rkill.com", "rkill.scr", "rkill.txt", "SecurityCheck.exe ", "RGSA.exe", "SAlog.txt", "CKScanner.exe", "CKFiles.txt", "OTL.exe", "OTL.com", "OTL.scr", "OTL.txt", "Extras.txt", "OTS.exe", "OTS.txt", "OTA.exe", "OTA.txt", "RSIT.exe", "RSITx64.exe", "OTC.exe", "Smitfraudfix.exe", "aswMBR.exe", "MBR.exe", "mbr.log", "tdsskiller.exe", "Flash_Disinfector.exe", "avenger.zip", "avenger.exe", "ComboFix.exe", "MiniToolBox.exe", "MTB.txt", "FSS.exe", "FSS.txt", "ExeFix.scr", "ExeFix.com", "ExeFix.bat", "ExeFix.cmd", "ExeFix.pif", "DeFogger.exe", "sc-cleaner.exe", "RogueKillerCMD.exe", "TFC.exe", "TFC.txt", "HijackThis.exe", "HijackThis.log", "MbrScan.exe", "Unhide.exe", "F-SecureOnlineScanner.exe", "SystemLook.exe", "SystemLook_x64.exe", "SystemLook.txt", "RestoreBFE.exe"] Local $sMask For $i = 0 To UBound($aFiles) - 1 $sMask &= $aFiles[$i] & ";" Next $sMask = StringTrimRight($sMask, 1) ;All of this makes the filemask we end up searching for below Local $b = _FileListToArrayRec(@UserProfileDir, $str, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) ;This is the array created from searching the user profile If @error Then Local $b[1] $b[0] = 0 EndIf FileDeleteArrayLoop($b) Func FileDeleteArrayLoop($Files) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = "" $len = $Files[0] For $i = 1 To $len $aPathSplit = _PathSplit($Files[$i], $sDrive, $sDir, $sFileName, $sExtension) If $sFileName == "ComboFix" Then ;_log("*** ComboFix remnants found. Please uninstall Combofix using its built-in uninstaller. ***") MsgBox(0, "", "Please uninstall ComboFix first") Else If FileDelete($Files[$i]) = 1 Then ; _log('Deleted - ' & $Files[$i]) ;===> Add's each filename to the log and marks as deleted MsgBox(0, "Deleted Items", "Deleted - " & $Files[$i]) Else ;_log(' *** Delete Failed for file = ' & $Files[$i]) ;===> If delete fails we add each to the log and label as failed MsgBox(8208, "Tool Cleanup APP", "There was a problem deleting the files. Check permissions or if the files are open and then try again.") ;===> Tell you it failed EndIf EndIf Next EndFunc ;==>FileDeleteArrayLoop Does this look right? It works, a bit slow, can it be improved? Edited December 2, 2018 by Nunos 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