Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

In Command Prompt, del /f can delete a read-only file, but it cannot unlock a file that another program currently has open. For an in-use file, identify the process holding it, close that process safely, and then retry the deletion. First verify the exact path: Microsoft warns that a file deleted with DEL cannot be retrieved through the usual deletion workflow.

Check what is making the file “locked”

“Locked” can mean different things in Windows. A read-only attribute is handled by a different option than an open handle, and neither is the same as an access-control problem or file-system corruption.

What you see What to try Important limit
The file is read-only del /f /f forces deletion of read-only files; it does not release another program’s open handle. Microsoft Learn: DEL
Windows says the file is in use Find and close the process using it, then retry DEL. A process may need to release its open handle before Windows allows deletion. Microsoft NTFS troubleshooting
Deletion still fails for another reason Diagnose the reported error, including permissions or file-system condition. DEL switches are not a general permissions or corruption repair. Microsoft NTFS troubleshooting

Delete a file safely from CMD

  1. Inspect the exact target

    Open Command Prompt and list the containing folder, quoting a path that contains spaces:
    dir "C:pathtofolder"
    Check the file name carefully before deleting it. Avoid broad wildcards; if you intend to use one, Microsoft advises first running DIR with the same wildcard to inspect the matches. Do not add /s unless you mean to delete matching files in subdirectories as well. Microsoft Learn: DEL

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Try ordinary deletion first

    For a single file, run:
    del "C:pathtofolderfile.ext"
    Add /p if you want CMD to prompt before deleting. Microsoft Learn: DEL

    #1 Best Overall
  3. Use /f only for a read-only file

    If the file’s read-only attribute is the obstacle, run:
    del /f "C:pathtofolderfile.ext"
    The /f option forces deletion of read-only files. It is not a way to bypass an open-handle lock, fix permissions, or repair file-system damage. Microsoft Learn: DEL

If another program is using the file

When Windows reports that a file is in use, identify the process that has it open and close the application normally if possible. Microsoft’s troubleshooting guidance explains that the file may not be deletable until the process releases its handle. Microsoft NTFS troubleshooting

Rank #2
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 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 handle

Microsoft Sysinternals Process Explorer can search for processes holding particular handles. The Handle utility displays open file references and requires administrative privileges. These tools help identify the owner; they do not make it safe to terminate an unknown process. Process Explorer

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Close a process from CMD only when it is safe

Use tasklist to find the process and its PID, then verify that the process is the one preventing deletion and that stopping it will not disrupt important work. A normal termination by PID uses:

Rank #3
15.6 Inch Laptop Computer, N4020, 4GB DDR4 RAM, 128GB eMMC,with Windows 11
  • EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
  • 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
  • RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
  • ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
  • LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.

taskkill /pid 1234

1234 is only an example; substitute the verified PID. If a normal close is not possible and you have confirmed the target is safe to stop, taskkill /f /pid 1234 forcefully ends it. The /t option also ends child processes. Forceful termination can discard unsaved work or disrupt the application, so do not target processes broadly. Microsoft Learn: TASKKILL

After the application or process has closed and released the handle, retry the appropriate DEL command.

Rank #4
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • 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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

If deletion still fails

Read the specific error rather than escalating deletion switches. An access-control issue and file-system corruption are different from a process holding the file open. Microsoft’s NTFS troubleshooting guidance covers other causes and checking file-system condition; use diagnosis suited to the error you actually receive. Microsoft NTFS troubleshooting

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

DEL switches to know

Microsoft documents the syntax as del [/p] [/f] [/s] [/q] [/a[:]<attributes>] <names>. The switches control different behaviors:

  • /p prompts before deleting.
  • /f forces deletion of read-only files.
  • /s deletes matching files in the current directory and its subdirectories.
  • /q suppresses confirmation.
  • /a[:<attributes>] selects files by attributes.

Because /s, /q, and wildcards can widen or obscure what is removed, inspect the target before running a command that uses them. Microsoft Learn: DEL

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$245.99
Bestseller No. 2
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$285.00

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.