If you want to recover deleted, corrupted or shortcut files, you can definitely use the third-party data recovery software (get MiniTool Power Data Recovery from MiniTool Solution ). However, you still have another choice: using the Command Prompt. It provides a free way for everyone to restore the deleted or lost files from USB drives, hard disks, and other storage devices.

CMD, the acronym of Command Prompt (also known as cmd.exe), is actually a command-line interpreter application you can find in any Windows operating systems. This tool provides you with a command-line interface to interact with the system. With it, you can do a lot of things on PC:

  • Delete files and folders
  • Manage disk and partition space
  • Modify drive properties
  • Solve disk problems

What’s more inspiring is that the CMD can also help you recover lost data. I’m going to demonstrate the exact steps to recover files using CMD in different cases. After that, I’ll also introduce another way to recover deleted files on Windows ( how to retrieve deleted files on PC? ).

recover files using CMD

Recover Files Using CMD: Exact Steps

Command Prompt is a snap-in tool in Windows systems, so you can open and use it easily for disk management , error fixing and data recovery. Your data can get lost due to a lot of reasons, such as accidental deletion, formatting and virus attack. Therefore, it’s necessary to teach you how to recover files using Command Prompt in some popular cases.

How to Recover Deleted Files Using Command Prompt

Generally, I advise you to check Recycle Bin when you delete files but find them still useful. Recycle Bin gives you a second chance for your mistaken deletion; it will store the accidentally deleted data for a certain period of time. Therefore, you can recover deleted files from Recycle Bin easily by dragging the files out directly or right clicking on needed files & choosing Restore.

There are some cases in which you have emptied the Recycle Bin or the file you have deleted is too large so it isn’t sent to the Recycle Bin. What should you do to recover the permanently deleted files ? Definitely, Command Prompt data recovery should be your choice.

How do you use CMD to recover lost or deleted files? (I’m taking Windows 10 as an example.)

  1. Right click on the Start button at the lower left corner to open a menu (you can also press Windows + X key combinations).
  2. Choose Command Prompt (Admin) from the menu (the steps to run Command Prompt as an administrator in other operating systems are slightly different).
  3. Type chkdsk *: /f (* stands for the drive letter of the certain drive containing deleted files) into the Command Prompt window and press Enter .
  4. Wait for the command to complete.
  5. Type that drive letter again and press Enter .
  6. Type attrib -h -r -s /s /d *.* and press Enter .
  7. Wait for the command to complete.

CHKDSK Deletes Your Data? Now Recover Them In Two Ways!

attrib command

Once the command has been finished, a new folder will be created on the drive to store all the recovered files, which will be in .chk format. You can finally change the format of those files and save them to the location you want. The CMD attrib command is usually used to recover permanently deleted files from CMD (you can also show hidden files using attrib command).

Please read this page if you are curious about where do deleted files go:

Where Do Deleted Files Go – Problem Solved
Where Do Deleted Files Go – Problem Solved

I find the question – where do deleted files go bothers a lot of people, so I decide to talk about it and then provide solutions for deleted file recovery.

Read More

What is CHK file?

In fact, CHK is the file extension for a temporary file format used in Windows. The CHK files are actually fragmented files which will be generated when:

  • The writing process of files into a drive is stopped suddenly.
  • The PC shuts down suddenly before you have a chance to save the opening files.

You can regard the CHK files as corrupted data.

What do these parameters in attrib command mean?

  • -h : it gives the Hidden attribute to the files specified.
  • -r : it refers to the read-only attribute (files can be read but cannot be changed).
  • -s : it gives the System attribute to the files specified.
  • /s : it tells the system to search the specified path (including subfolders).
  • /d : it consists of process folders.

How to fix if attrib access denied?

Step one : make sure you are running Command Prompt as administrator.

Step two : check if there is any file in use.

The access will be denied if any files contained in the target drive are still used by other programs when you are running the command.

  • Please close the programs and try again.
  • If this fails, you need to start the computer in Safe Mode when you can’t track down the files.

Step three: check if you have enough permissions.

  1. Open Windows Explorer to locate the drive you want to run attrib command on.
  2. Right click on it and choose Properties .
  3. Shift to the Security tab.
  4. Find To change permissions, click Edit. and click on the Edit… button behind it.
  5. Click on the Add… button in the middle part of the window and type your username to allow account access. (You can also choose Everyone and click OK in the Security window to allow anyone to access the drive.)
  6. Find Group or user names area under Security tab.
  7. Select the Allow check for Full control.
  8. Click OK to confirm.


Step four : please try to run the chkdsk /f command on the target drive from a DOS Command Prompt.

That’s all about how to recover CHK files using CMD.

Windows Explorer Needs To Be Restarted: Problem Solved.

Click to Tweet

How to Repair Damaged SD Card Using CMD

Normally, the flash memory is more susceptible to damage than hard drives. Pen drive and SD card are two of the popular flash storage devices which should be connected to a computer via USB in order to access files in them. How do you recover data when the drive is corrupted? Indeed, the Command Prompt can work as a powerful flash drive repair utility.

How to recover data from corrupted pen drive using CMD?

  • Actually, you can recover files from USB using CMD attrib (as I mentioned before).
  • Besides, the MiniTool Power Data Recovery can be a good USB recovery tool for you right after files disappeared from USB. Besides, you can use this software to recover files from SSD , external hard drives, SD card, and more.

Free Download

How to recover corrupted files from SD card:

  1. Connect the corrupted flash drive to your PC through the USB port (a card reader will be needed if you want to connect an SD card to PC).
  2. Install MiniTool Power Data Recovery on your computer properly. Then, launch it to recover data.
  3. Go to the Devices tab, instead of Logical Drives.
  4. Select your SD card/pen drive from the panel ( how to repair pen drive not detected? ).
  5. Click on the Scan button to start to search for the files contained in the drive.
  6. More and more files will be found by the data recovery software as the scan processes. Please browse them carefully to pick out the data you really need.
  7. Click on the Save button to specify a storage path in the prompt window. Then, click on the OK button there to confirm.
  8. Wait till all the selected files have been restored to the appointed path.

Scan pen drive

That's all about how to recover files from corrupted flash drive easily. You should click this link if you want free USB data recovery .

How to repair corrupted pen drive using CMD?

Method one: run chkdsk command.

  1. Plug the pen drive into the computer via USB port.
  2. Run Command Prompt as administrator.
  3. Type chkdsk *: /f /r /x (* stands for the correct drive letter) and hit Enter .
  4. Wait for the command to complete.

repair corrupted pen drive

Method two: run clean command.

How to format corrupted memory card using CMD? (Take Windows 10 as an example.)

  1. Connect the certain SD card/USB drive to your PC properly.
  2. Click on the Cortana icon or the search box on the taskbar.
  3. Type cmd and right click on Command Prompt (App) from the search result.
  4. Hit Yes in the User Account Control window to allow opening Windows Command Processor.
  5. Type diskpart and press Enter ( what if the DiskPart has encountered an error? ).
  6. Type list disk and press Enter .
  7. Type select disk * (* stands for the number displayed before the pen drive/SD card in the list) and press Enter .
  8. Type clean and press Enter .
  9. Type create partition primary and press Enter .
  10. Type active and press Enter .
  11. Type select partition 1 and press Enter .
  12. Type format fs=fat32 (you can also type format fs=fat32 ) and press Enter .
  13. Wait for the formatting process to finish.

format a corrupted drive

Sometimes, you are not recognized that there are still a lot of important files on the drive until the DiskPart clean command has been finished. Please don’t be panic; you can recover data from the cleaned drive easily by following tutorials here:

Recover Data Lost By DiskPart Clean – Complete Guide
Recover Data Lost By DiskPart Clean – Complete Guide

If you need to recover data lost by DiskPart clean, but have no experience, the software recommended in this page will be your great assistant.

Read More

How to Recover a Formatted Hard Drive Using CMD

How to recover data from the hard disk which doesn’t contain system partition ? You should run Command Prompt as administrator, then, type attrib command or chkdsk command into it and press Enter.

Also, you can make use of the rescan command to have a try.

  1. As I said, you should open CMD as administrator.
  2. Type diskpart into it and hit Enter .
  3. Type list disk and press Enter .
  4. Type select disk * and press Enter .
  5. Type rescan and hit Enter .
  6. Wait for the scan process to complete.
  7. Check if your files are recovered at the end.


However, what if the hard disk is an internal drive that is necessary for booting the system? How to recover data from hard disk using Command Prompt in this case? ( How to recover files from PC which can’t boot? )

You should start PC in Safe Mode, and then use CMD to repair hard disk .

How to boot Windows 10 in Safe Mode:

  1. Press Start + I buttons to open the Settings window.
  2. Select Update & Security from the window.
  3. Choose Recovery from the left-side panel.
  4. Find the Advanced startup area from the right-side panel.
  5. Click the Restart now button.
  6. Then, your computer will be restarted.

Restart now

How to use Command Prompt in Safe Mode:

  1. Select Troubleshoot from the Choose an option screen.
  2. Choose Advanced options .
  3. Click See more recovery options .
  4. Choose Startup Settings .
  5. Click Restart .
  6. Press F6 to Enable Safe Mode with Command Prompt.

Enable Safe Mode with Command Prompt

After that, you should type attrib/chkdsk/rescan command to try to recover files using CMD.

That’s how to fix corrupted hard drive using CMD.

There’s a better way to recover files from a corrupted/damaged/formatted hard disk – using MiniTool Power Data Recovery. Please read this page to know more details:

How To Recover Files From Formatted Hard Drive - Guide
How To Recover Files From Formatted Hard Drive - Guide

The work to recover files from formatted hard drive is not as difficult as you thought; the key factor is whether you have got a helpful tool.

Read More

Click to Tweet

Remove Virus Using CMD

If your computer has been attacked by a virus, you may find files turned into shortcuts ( how to recover files deleted by virus ). At this time, you are supposed to adopt shortcut remover CMD.

How to Remove Shortcut Virus

  1. Also, you need to run the Command Prompt as an administrator.
  2. Type the drive letter of the disk infected with virus and hit Enter .
  3. Type del *.lnk and hit Enter (you can also type ATTRIBUTE -H -R -S AUTORUN.INF and hit Enter to delete the autorun.inf file).
  4. Type attrib -s -r -h *.* /s /d /l and hit Enter .
  5. Wait for the command to finish.

remove shortcut virus

Besides, you can also run the attrib -h -r -s /s /d command to unhide files hidden by virus. For more information about how to unhide files, please read 4 Causes That Can Be Fixed Directly in Windows (Possible cause 1 – the files are hidden) part in this article:

Solved – Files Not Showing In External Hard Drive
Solved – Files Not Showing In External Hard Drive

This post tells why files are not showing in external hard drive from 5 aspects and it shows how to unhide files here safely.

Read More

Last Words

You can’t deny that the Command Prompt is a powerful tool which is built in Windows systems. It is able to help you manage flash drive/hard disk (format partition, deleted partition, etc.) safely. In addition, the CMD can be used to recover files from pen drive/SD card/hard disk. This post tells you how to recover files using Command Prompt and how to remove Shortcut Virus from laptop/desktop step by step.

Please read the corresponding part carefully if you need to recover files using CMD.

Samsung Data Recovery - 100% Safe and Effective Solutions
Samsung Data Recovery - 100% Safe and Effective Solutions

You may need to perform a safe and reliable Samsung data recovery for your computer/phone/tablet/external data storage drive and this article is helpful.

Read More

  • Linkedin
  • Reddit