del /f in Command Prompt can delete a read-only file, but it cannot unlock a file that another program is using. For an in-use file, find the process holding it open, close that process safely, and then retry the deletion. First confirm the exact file path: Microsoft warns that a file deleted with del cannot be recovered through the usual Recycle Bin workflow.
Before deleting a file from Command Prompt
del deletes files directly, so check the target before running it. Open Command Prompt and inspect the folder with dir, quoting any path that contains spaces:
As an Amazon Associate I earn from qualifying purchases.
dir "C:pathtofolder"
Microsoft advises checking which files match a wildcard with dir before using that wildcard with del. Avoid broad wildcards and the recursive /s switch unless you intend to delete matching files in subfolders as well. See Microsoft’s DEL command reference.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Delete a read-only file with DEL /F
Try a normal deletion first. Replace the example path with the verified file path:
#1 Best Overall
- 14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
del "C:pathtofolderfile.ext"
Add /p if you want Command Prompt to ask for confirmation before deleting:
del /p "C:pathtofolderfile.ext"
If the file has the read-only attribute, use /f:
del /f "C:pathtofolderfile.ext"
Microsoft documents /f as forcing deletion of read-only files. It is not a general unlock switch: it does not release a process’s open handle, fix access permissions, or repair file-system corruption.
If Windows says the file is in use
A file held open by another process may not be deletable until that process releases its handle. Microsoft’s NTFS file and folder troubleshooting guide recommends determining which process is using the file and closing it.
Recommended Free Tools
Close the application normally
If you recognize the application, save any work and close it normally. Then retry del. This is the safest first option because it lets the application release the file handle cleanly.
Rank #2
- 256 GB SSD of storage.
- Multitasking is easy with 16GB of RAM
- Equipped with a blazing fast Core i5 2.00 GHz processor.
Find the process holding the file
Microsoft Sysinternals Process Explorer can search for processes holding particular handles. The command-line Handle utility displays open file references and requires administrative privileges. Use one of these tools to identify the process before deciding whether it is safe to stop.
Stop a known-safe process from CMD
Use tasklist to inspect running processes and identify the correct process ID (PID):
tasklist
After verifying the PID and that the process can safely be closed, end it with taskkill:
taskkill /pid 1234
1234 is an example only; substitute the verified PID. Microsoft documents taskkill as ending tasks by PID or image name. Its /f option forces termination, while /t also ends child processes. Forceful termination can lose unsaved work or disrupt other activity, so do not use it broadly or against a process you have not identified. After the process closes and releases the handle, retry del. See the TASKKILL command reference.
Rank #3
- WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
- 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
- 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
- CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
- LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
Choose the fix that matches the error
| What is happening | What to do | Important limitation |
|---|---|---|
| The file is read-only | Try del /f "C:pathtofile.ext". |
/f is for read-only files; it does not resolve an open handle. |
| Another program is using the file | Identify and close the owning application or process, then retry del. |
Stopping the wrong process can disrupt work or lose unsaved changes. |
| You need to end a process from CMD | Verify the process with tasklist, then use taskkill with its PID or image name. |
/f forcefully ends it; /t also ends child processes. |
| The file still cannot be deleted | Diagnose the specific error, including permissions or possible file-system problems. | DEL switches are not a universal repair for access-control issues or corruption. |
DEL switches to use carefully
Microsoft documents this syntax: del [/p] [/f] [/s] [/q] [/a[:]<attributes>] <names>. In practical terms:
/pprompts before each file is deleted./fforces deletion of read-only files./sdeletes matching files from the current directory and its subdirectories./qsuppresses confirmation./aselects files by attributes.
Wildcards are supported, but they can match more files than expected. Inspect the matches with dir before using them with del, and avoid adding /s unless recursive deletion is intended.
When deletion still fails
If the process has been closed and the file still will not delete, do not keep adding force switches. Read the exact error and distinguish an open-handle problem from an access-control issue or a possible file-system problem. Microsoft’s NTFS troubleshooting guide discusses corruption as another reason deletion may fail; the right next step depends on the specific error and condition.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




