Jump to content

Missing something


Nunos
 Share

Recommended Posts

#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

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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:

#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 by Nunos
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...