Clear prefetch folder
- Windows onlyThis script improves your privacy on Windows
- Single actionThis page belongs to a script, containing basic changes to achieve a task.
- Impact: Minimum
System Functionality / Data Loss Risk: Low
This action improves privacy with minimal impact when you run the recommended script.
- Batch (batchfile)These changes use Windows system commands to update your settings.
- Administrator rights requiredThis script requires privilege access to do the system changes
- Fully reversible
You can fully restore this action (revert back to the original behavior) using this website.
The restore/revert methods provided here can help you fix issues.
Overview
This script deletes the contents of %SYSTEMROOT%\Prefetch\*
, typically pointing to C:\Windows\Prefetch\
1 2.
What is Prefetch?
Introduced in Windows XP 2, Prefetch was developed by Windows to expedite application startup 1 and the boot process 1 2. It works by preemptively loading data and code pages into memory from the disk before requests 2, monitoring application's startup page faults 2, and storing the gathered data in the Prefetch directory 2.
Why Clear the Prefetch Directory?
Over time, many files accumulate in the Prefetch directory. Clearing this directory enhances privacy and potentially frees disk space by removing traces of recently used applications and files in the system, making unauthorized tracking of application usage more difficult. Despite its design for improving application startup times 1, Prefetch can inadvertently expose information about the applications and files accessed on the system 1. Clearing the Prefetch directory addresses this issue by eliminating these traces.
Microsoft suggests deleting the Prefetch directory and its contents if significant system configuration changes occur, like adjustments to drivers, services, or applications that start automatically 3. This action eradicates any outdated prefetched data 3, ensuring that the system operates with the most up-to-date and relevant data for application startups 3.
The files in the Prefetch directory are used for forensic purposes 4 5, adding to the privacy concerns. They reveal information about application usage, including data layout 4, access history on disk 4, last execution time 5, and the total number of times an application has been run 5. Additionally, they contain historical process information such as loaded libraries and process dependencies 6. Erasing these files mitigates the risk of this information being used for unauthorized tracking or analysis, improving your privacy.
Trade-Off
Clearing the Prefetch might cause a minor delay in application startup times until the necessary data is regenerated as applications are used again 2. This is a compromise for heightened privacy and potentially freed disk space.
Sources
- Take response actions on a device in Microsoft Defender for Endpoint. Microsoft Learn. (2023).
Original: https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/respond-machine-alerts
Archived: https://web.archive.org/web/20231001151015/https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/respond-machine-alerts?view=o365-worldwide#collect-investigation-package-from-devices - Sysinternals Newsletter Vol. 3, No. 2 - Sysinternals. Microsoft Learn. (2023).
Original: https://learn.microsoft.com/en-us/sysinternals/resources/archive/v03n02
Archived: https://web.archive.org/web/20231001151029/https://learn.microsoft.com/en-us/sysinternals/resources/archive/v03n02#windows-xp-prefetching - Performance Testing Guide for Windows. Microsoft. (2023).
Original: https://download.microsoft.com/download/7/e/7/7e7662cf-cbea-470b-a97e-ce7ce0d98dc2/win7perf.docx
Archived: https://web.archive.org/web/20230829142700/https://download.microsoft.com/download/7/e/7/7e7662cf-cbea-470b-a97e-ce7ce0d98dc2/win7perf.docx - A Prefetching Scheme Exploiting both Data Layout and Access History on Disk. ccsweb.lanl.gov. (2023).
Original: https://ccsweb.lanl.gov/~kei/mypubbib/papers/TOS_13_diskseen.pdf
Archived: https://web.archive.org/web/20231001151107/https://ccsweb.lanl.gov/~kei/mypubbib/papers/TOS_13_diskseen.pdf - Computer Forensics. justice.gov. (2023).
Original: https://www.justice.gov/sites/default/files/usao/legacy/2008/02/04/usab5601.pdf
Archived: https://web.archive.org/web/20231001151150/https://www.justice.gov/sites/default/files/usao/legacy/2008/02/04/usab5601.pdf - Malware Family Classification via Residual Prefetch Artifacts. par.nsf.gov. (2023).
Original: https://par.nsf.gov/servlets/purl/10333089
Archived: https://web.archive.org/web/20231001151207/https://par.nsf.gov/servlets/purl/10333089
Apply Now
Choose one of three ways to apply:
Download script
Download and run the script directly- No app needed
- Offline usage
- Easy-to-apply
- Free
- Open-source
Help
How to apply or restore "Clear prefetch folder" using script
- ≈ 2 min to complete
- Tools: Web Browser
- Difficulty: Simple
- ≈ 5 instructions
- 1
Download
Download the script file by clicking on thebutton above.
Use button above to restore changes. - 2
Keep the file
If warned by your browser, keep the file. - 3
Open
Open the downloaded file. - 4
Exit
Once it's done, press any key to exit the window. - 5
Restart
Restart your computer for all changes to take effect.
Apply with privacy.sexy
Guided, automated application with safety checks- Recommended for most users
- Includes safety checks
- Free
- Open-source
- Popular
- Offline/Online usage
Help
How to apply or restore "Clear prefetch folder" using privacy.sexy
- ≈ 3 min to complete
- Tools: privacy.sexy
- Difficulty: Simple
- ≈ 4 instructions
- 2
Choose script
- Search for the script name: Clear prefetch folder
- Check the script by clicking on the checkbox.
- 3
Run
Click on ▶️ Run button at the bottom of the page.This button only appears on desktop version (recommended). On browser, use 💾 Save button.
- Apply
- Revert
:: Clear directory contents : "%SYSTEMROOT%\Prefetch"
PowerShell -ExecutionPolicy Unrestricted -Command "$pathGlobPattern = "^""$($directoryGlob = '%SYSTEMROOT%\Prefetch'; if ($directoryGlob.EndsWith('\*')) { $directoryGlob } elseif ($directoryGlob.EndsWith('\')) { "^""$($directoryGlob)*"^"" } else { "^""$($directoryGlob)\*"^"" } )"^""; $expandedPath = [System.Environment]::ExpandEnvironmentVariables($pathGlobPattern); Write-Host "^""Searching for items matching pattern: `"^""$($expandedPath)`"^""."^""; $deletedCount = 0; $failedCount = 0; $foundAbsolutePaths = @(); Write-Host 'Iterating files and directories recursively.'; try { $foundAbsolutePaths += @(; Get-ChildItem -Path $expandedPath -Force -Recurse -ErrorAction Stop | Select-Object -ExpandProperty FullName; ); } catch [System.Management.Automation.ItemNotFoundException] { <# Swallow, do not run `Test-Path` before, it's unreliable for globs requiring extra permissions #>; }; try { $foundAbsolutePaths += @(; Get-Item -Path $expandedPath -ErrorAction Stop | Select-Object -ExpandProperty FullName; ); } catch [System.Management.Automation.ItemNotFoundException] { <# Swallow, do not run `Test-Path` before, it's unreliable for globs requiring extra permissions #>; }; $foundAbsolutePaths = $foundAbsolutePaths | Select-Object -Unique | Sort-Object -Property { $_.Length } -Descending; if (!$foundAbsolutePaths) { Write-Host 'Skipping, no items available.'; exit 0; }; Write-Host "^""Initiating processing of $($foundAbsolutePaths.Count) items from `"^""$expandedPath`"^""."^""; foreach ($path in $foundAbsolutePaths) { if (-not (Test-Path $path)) { <# Re-check existence as prior deletions might remove subsequent items (e.g., subdirectories). #>; Write-Host "^""Successfully deleted: $($path) (already deleted)."^""; $deletedCount++; continue; }; try { Remove-Item -Path $path -Force -Recurse -ErrorAction Stop; $deletedCount++; Write-Host "^""Successfully deleted: $($path)"^""; } catch { $failedCount++; Write-Warning "^""Unable to delete $($path): $_"^""; }; }; Write-Host "^""Successfully deleted $($deletedCount) items."^""; if ($failedCount -gt 0) { Write-Warning "^""Failed to delete $($failedCount) items."^""; }"
IiI=
Help
How to apply or restore "Clear prefetch folder" using commands
- ≈ 2 min to complete
- Tools: Command Prompt
- Difficulty: Medium
- ≈ 3 instructions
- 1
Open Command Prompt
Open Command Prompt as Administrator. - 2
Copy code
Copy the code: - 3
Paste & run
Paste the commands into Command Prompt and press Enter to run.Some changes require a system restart to take effect
Similar Guides
Wider Goal
Guides below includes this guide to achieve a wider goal.See other more general settings that includes this one as one of its actions.
These plans combine multiple privacy settings, including this one, for stronger protection.
- Clear temporary Windows files
- Privacy cleanup
This category covers removal of temporary Windows files. It is recommended to clean these files as they can be used for unauthorized analysis of user behavior and ...
Privacy cleanup to protect your data with support of proper personal data control on Windows — Read along, this system calibration illustrates just that. What's eq...
Same Goal
Other guides in Clear temporary Windows filesSee settings that are in the same category as this guide.
Using other actions in the same category may help you achieve your goal better.
About the Creators
These people have authored this documentation and written its scripts:
Reviewed By
This guide has undergone comprehensive auditing and peer review:Expert review by undergroundwires
- Verified technical accuracy and editorial standards
- Assessed system impact and user privacy risks
Public review by large community
- Privacy enthusiasts and professionals peer-reviewed
- Millions of end-users tested across different environments
History
We continually monitor our guides, their impact and all other privacy options. We update our guides when new information becomes available. On every update, we publicly store who made the change, what has been changed, why the change was made and when the change was made.