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: 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.)
- Right click on the Start button at the lower left corner to open a menu (you can also press Windows + X key combinations).
- Choose Command Prompt (Admin) from the menu (the steps to run Command Prompt as an administrator in other operating systems are slightly different).
- Type chkdsk *: /f (* stands for the drive letter of the certain drive containing deleted files) into the Command Prompt window and press Enter .
- Wait for the command to complete.
- Type that drive letter again and press Enter .
- Type attrib -h -r -s /s /d *.* and press Enter .
- Wait for the command to complete.
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:
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.
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.
- Open Windows Explorer to locate the drive you want to run attrib command on.
- Right click on it and choose Properties .
- Shift to the Security tab.
- Find To change permissions, click Edit. and click on the Edit… button behind it.
- 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.)
- Find Group or user names area under Security tab.
- Select the Allow check for Full control.
- Click OK to confirm.
That’s all about how to recover CHK files using CMD.
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.
How to recover corrupted files from SD card:
- 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).
- Install MiniTool Power Data Recovery on your computer properly. Then, launch it to recover data.
- Go to the Devices tab, instead of Logical Drives.
- Select your SD card/pen drive from the panel ( how to repair pen drive not detected? ).
- Click on the Scan button to start to search for the files contained in the drive.
- 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.
- Click on the Save button to specify a storage path in the prompt window. Then, click on the OK button there to confirm.
- Wait till all the selected files have been restored to the appointed path.
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.
- Plug the pen drive into the computer via USB port.
- Run Command Prompt as administrator.
- Type chkdsk *: /f /r /x (* stands for the correct drive letter) and hit Enter .
- Wait for the command to complete.
Method two: run clean command.
How to format corrupted memory card using CMD? (Take Windows 10 as an example.)
- Connect the certain SD card/USB drive to your PC properly.
- Click on the Cortana icon or the search box on the taskbar.
- Type cmd and right click on Command Prompt (App) from the search result.
- Hit Yes in the User Account Control window to allow opening Windows Command Processor.
- Type diskpart and press Enter ( what if the DiskPart has encountered an error? ).
- Type list disk and press Enter .
- Type select disk * (* stands for the number displayed before the pen drive/SD card in the list) and press Enter .
- Type clean and press Enter .
- Type create partition primary and press Enter .
- Type active and press Enter .
- Type select partition 1 and press Enter .
- Type format fs=fat32 (you can also type format fs=fat32 ) and press Enter .
- Wait for the formatting process to finish.
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:
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.
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.
- As I said, you should open CMD as administrator.
- Type diskpart into it and hit Enter .
- Type list disk and press Enter .
- Type select disk * and press Enter .
- Type rescan and hit Enter .
- Wait for the scan process to complete.
- 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:
- Press Start + I buttons to open the Settings window.
- Select Update & Security from the window.
- Choose Recovery from the left-side panel.
- Find the Advanced startup area from the right-side panel.
- Click the Restart now button.
- Then, your computer will be restarted.
How to use Command Prompt in Safe Mode:
- Select Troubleshoot from the Choose an option screen.
- Choose Advanced options .
- Click See more recovery options .
- Choose Startup Settings .
- Click Restart .
- Press F6 to 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:
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.
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
- Also, you need to run the Command Prompt as an administrator.
- Type the drive letter of the disk infected with virus and hit Enter .
- 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).
- Type attrib -s -r -h *.* /s /d /l and hit Enter .
- Wait for the command to finish.
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:
This post tells why files are not showing in external hard drive from 5 aspects and it shows how to unhide files here safely.
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.