[Detailed Guide] How to Use CMD to Recover Files

You may want to use the inbuilt Command Prompt in Windows to recover files but don’t know how. This guide will tell you how to use CMD to recover files that lost in different situations.


By Demi / Updated on June 14, 2022

Share this: instagram reddit

You can recover deleted/lost data from external hard drive, pen drive, USB flash drive, etc. with the help of the built-in Windows utility Command Prompt. You may have heard about it but never use it. Here in this page, you can get CMD command for recovering deleted/lost files, as well as the detailed steps of how to use them to recover data on your hard drive/computer.

Overview of Command Prompt for data recovery

CMD, the acronym of Command Prompt, which is a command-line interpreter program that can be found on any Windows operating system, can do you a favor in recovering files after hiding, accidental deletion, corrupting, or virus attacking.

Since it is pre-installed on Windows and no need to download anymore, you can make full use of CMD to recover deleted files on Windows. However, compared to professional data recovery software for Windows, it has got some disadvantages.

😔 You need to enter the command line manually. Therefore, CMD is not appropriate for computer newbies.

😔 CMD cannot promise to recover all lost files for you. In other words, you may still encounter data loss after using CMD to recover files.

😔 If you wonder how to recover permanently deleted files using CMD, you may be disappointed with CMD. The permanently deleted files have difficulty being fully recovered using CMD. Besides, it may fail to recover files in other complex data loss scenarios, either.

How to use CMD to recover files on Windows

In this part, you will be given three scenarios to use CMD to recover files on your Windows computer. Please be careful when utilizing command lines. A small error in type can cause serious consequences.

Scenario 1. Recover files using CMD Attrib

🔊 Applicable to: Deleted, lost, hidden and virus-corrupted files recovery

CMD Attrib can be used to recover hidden files caused by inappropriate operations or virus attack. The detailed steps to recover corrupted files using CMD command are as follows. If you need to recover files in USB drive, hard drive, etc., plug it into your computer first.

Step 1. Go to the Start menu, type in cmd in the search bar > From the search result, locate and right click cmd.exe.

Step 2. After the command window prompts, type in attrib -h -r -s /s /d #:*.* (Replace # with the drive letter of your hard drive or external storage device where you lost files.)

Type Attrib

To some degree, CMD Attrib is not a real file recovery tool. It allows you the same access to settings as if you right-clicked on a file.

Scenario: Recover deleted files using Command Prompt

🔊 Applicable to: Deleted files recovery, recycle bin file recovery

When the Recycle Bin is full, most Windows users will remove a file to free up room for files that have been recently deleted. However, until the Recycle Bin is empty, these deleted files are still recoverable. You can use CMD prompt to recover deleted files by following steps below.

Step 1. Go to the Start menu, type cmd in the search bar > Locate and click cmd.exe to open the command prompt.

Step 2. Type start shell: RecycleBinFolder and press Enter. Then, you can select the files to restore.

Recover Deleted Files With CMD Prompt

Scenario 3. Recover files using chkdsk and rescan Command

🔊 Applicable to: RAW file system or corrupted file system recovery

If your data is lost, and you merely want to repair your corrupted external hard drive. You can follow the steps to recover files using chkdsk and rescan Command. If you need to recover files from external storage devices, connect to your computer in advance.

Step 1. Input cmd in the search bar of Windows > Click Command Prompt > Click Open. (Choose Run as administrator if necessary).

Step 2. On the command window, type chkdsk #: /f /r (Replace # with the letter of your storage device). Hit the Enter key.


Step 3. On the next command prompt window, type diskpart, and hit on Enter > Type rescan and hit Enter.

Rescan Command

Step 4. Exit diskpart, type chkdsk /f #: in CMD and hit Enter. Replace # with the drive letter of your storage device.

An easier way to recover files with the best CMD alternative

Since using CMD to recover files is limited in many situations, you may need a CMD alternative to recover files without any data loss. MyRecover can completely replace the command prompt, allowing you to:

✔ Support recovering all-inclusive types of files. All lost files like photos, videos, audio files, etc. can all be recovered by this powerful data recovery software.
✔ Apply to different data loss situations. MyRecover can help you recover lost files due to accidental deletion, disk formatting, system crash, virus attack, etc. with no effort.
✔ Scan lost files deeply and quickly. MyRecover is equipped with an advanced scanning algorithm, which helps quickly and deeply scan your computer and filter the deleted and lost files.
✔ Finish recovering files within a few clicks. It is pretty easy to use the software. With simple clicks, you can get all wanted files back.

Free download MyRecover on your computer, and follow the simple three steps to retrieve files with it. Please connect your storage devices to computer in advance if necessary.

Download SoftwareWin 11/10/8/7/Server
Secure Download

Step 1. Open MyRecover on your computer > Choose the exact disk where your files are lost > Click Start Scan to let the tool scan your disk.

Select Partition To Scan

Step 2. Wait for the scan process to finish. From the Scanned files list, you can click each folder to browse the deleted/lost files.

Scan Lost Data

Step 3. Choose the lost files you’d like to recover > Click Recover x files > Finally, choose a destination to save the files, and the recovery process will be finished in seconds.

Recover Lost Data


That’s all for the instructions about how to use CMD to recover files. Please remember that you need to be very careful when utilize CMD on your Windows computer.

To recover files without any effort, you can also try the professional data recovery software mentioned in this guide. If this guide is helpful, please share it with others.

Demi · Editor
Doris is an editor of AOMEI Technology as well as a good advisor in the area of iOS-related issues. She does well in finding solutions to people's problems. She enjoys traveling, gardening, and watching movies. She spends most of her free time with her pet and family.