Deleting item from prefetch / random characters behind filename

Hey, i'm just wondering if theres a specific way to delete items (in my case .pf files) that are named randomly?

The files save like this every time chrome.exe is opened:

CHROME.EXE-5349D2D7
CHROME.EXE-5349D2D9

I need a way to specify my program to delete these from my folder, if not ONLY the most recent one if possible.

Thank you for the help!

 
DeleteFile("\\\\.\\C:\Windows\Prefetch\\CHROME.EXE");
Look up FindFirstFile (and FindNextFile) on MSDN. I think it allows you to pass something like this "C:\\Windows\\Prefetch\\CHROME.EXE*" and it will return all matching files. Then you can delete them.
Last edited on
I figured it out this way:

1
2
3
4
5
6
7
8
9
10
11
12
{
    WIN32_FIND_DATAW fd;
    HANDLE hFind = FindFirstFileW(L"C:\\Windows\\Prefetch\\RUNDLL32.EXE-*.pf", &fd);
    if (hFind != INVALID_HANDLE_VALUE)
    {
        do
        {
            DeleteFileW((wstring(L"C:\\Windows\\Prefetch\\") + fd.cFileName).c_str());
        } while (FindNextFileW(hFind, &fd));
        FindClose(hFind);
    }
}


Thank you!
Topic archived. No new replies allowed.