When files go missing from a USB flash drive, it’s easy to think you need specialized software to recover them. But in many cases, all you really need is the Command Prompt (CMD) and the built-in tools that come with Windows. These built-in tools can help you recover deleted files, fix corrupted drives, and even reveal files hidden by malware. Let’s take a closer look at how to use them.
When to Use Command Prompt for Flash Drive Recovery
The Command Prompt offers built-in tools for flash drive recovery on Windows systems. Understanding when to utilize these commands can help you choose the most appropriate recovery approach for your situation.
Here are some situations when using CMD for recovery is a good choice:
- When you can’t or don’t want to install additional software: Arguably the biggest advantage of CMD recovery tools in Windows is that they ship with the operating system. This is especially useful when working on a computer where you don’t have administrator rights, such as when dealing with security-restricted corporate environments.
- When performing a remote recovery: Let’s say you’re helping someone you know recover data from their USB flash drive via remote access to the command prompt (such as through SSH). In a situation like that, CMD commands are ideal because they don’t require you to have access to the Windows GUI and work reliably even on slow connections.
- When your system is unstable: After malware attacks, failed system updates, or customization attempts go wrong, third-party software might not run properly. In fact, you might not even be able to boot into Windows. However, CMD recovery commands can still be executed from your Windows installation medium or Safe Mode.
Basically, it makes sense to recover data from a USB flash drive using the CMD when your recovery needs are straightforward or when working in environments where graphical interfaces are unavailable or impractical.
Must-Try CMD Flash Drive Recovery Methods
There are a few key CMD methods that every Windows user should know. I’m going to walk you through them one by one while providing you with step-by-step instructions that you can easily follow, even if you don’t have any previous experience with CMD USB flash drive recovery.
Method 1: Recycle Bin
Best for: Recovering recently deleted files.
This method helps you recover files that were recently deleted and are still in the Recycle Bin. Use it when you can’t open the Recycle Bin by double-clicking its desktop icon, such as when the icon has disappeared, or when nothing happens when you click on it.
To recover flash drive files from the Recycle Bin using CMD:
- Open the Start menu and type “cmd”. Open Command Prompt from the list of results (it should be at the top).
- Paste the following command into the Command Prompt window and press Enter: start shell:RecycleBinFolder
- The Recycle Bin folder should now open. From here, you can select the files you want to restore, right-click on them, and select Restore. Alternatively, you can drag them back to the USB flash drive or any other location on your computer.
Keep in mind that this method won’t help you recover files that are not present in the Recycle Bin. It simply provides an alternative way to open the Recycle Bin, one that doesn’t depend on the Recycle Bin icon.
If the above command doesn’t open the Recycle Bin, you can try accessing it using its GUID (Globally Unique Identifier) instead. Copy & paste the following command into CMD and press Enter:
explorer ::{645FF040-5081-101B-9F08-00AA002F954E}
Again, this should open the Recycle Bin in File Explorer, where you can then move the deleted files to a safe location.
Method 2: ATTRIB (Attribute) Command
Best for: Regaining access to files after a malware infection or user error.
Files and entire directories on your USB flash drive can have various attributes that control how they are accessed. What sometimes happens is that a user makes a mistake or malware infects a USB flash drive and changes the attributes of all files stored on it, making it seem like your files have disappeared.
In reality, the files are still present on the USB flash drive—it’s just that they’ve been hidden from view. To fix this issue and regain access to your files, you need to perform command prompt flash drive recovery using the ATTRIB command, whose purpose is to display, set, and remove attributes assigned to files and directories.
In order to use the ATTRIB command to recover hidden files from your USB flash drive, you need to:
- Launch the CMD by searching for it in the Start menu.
- Type the letter assigned to your USB flash drive followed by a colon (such as “E:” or “D:”) and hit Enter.
- Paste the following command into the Command Prompt window and press Enter: attrib -h -r -s /s /d *.* (make sure to replace DRIVE_LETTER with the letter assigned to your USB flash drive)
- Open File Explorer and navigate to your USB flash drive. All lost files should be right there, and you shouldn’t have any trouble opening them.
Here’s a detailed explanation of the command you’ve just used:
- -h clears the Hidden file attribute.
- -r clears the Read-only file attribute.
- -s clears the System file attribute.
- /d applies attrib and any command-line options to directories.
- /s applies attrib and any command-line options to matching files in the current directory and all of its subdirectories.
- *.* specifies that you want to apply the attrib to all files in the current directory.
As you can see, the command isn’t nearly as complicated as it seems at first. It simply performs multiple file management operations at the same time, saving you time and allowing you (at least in theory) to instantly regain access to lost files.
Method 3: CHKDSK (Check Disk) Command
Best for: Repairing files that have become inaccessible due to flash drive corruption.
Sometimes, the data stored on a USB flash drive becomes corrupted and, as a result, impossible to access. This can happen if files are transferred between different operating systems, if the USB flash drive is very old, or if some strange data transfer issue has occurred.
Fortunately, there’s a handy command-line utility called CHKDSK included in Windows that you can use to check your USB flash drive for logical issues.
Follow these steps to repair files on a USB flash drive with CHKDSK:
- Open the start menu and type “cmd”. Hit Enter on your keyboard.
- Enter the following command (make sure to replace DRIVE_LETTER with the letter assigned to the hard drive you want to fix) and press Enter: chkdsk DRIVE_LETTER: /r
- Wait for CHKDSK to finish.
The /r parameter tells CHKDSK to locate bad sectors, attempt to recover readable information, and repair errors. You can also use the /f parameter if you only want to fix errors, without scanning for bad sectors. If CHKDSK identifies lost file fragments, it will save them as .chk files on the USB flash drive.
Tip: There are many utilities that you can try to recover usable data from the .chk files created by the CHKDSK /r parameter, including UnCHK, FileCHK, and CHK-Mate. They all do more or less the same, so it doesn’t matter too much which one you try first.
Method 4: Windows File Recovery
Best for: Recovering permanently deleted files.
The methods we’ve covered so far are effective for many data loss scenarios, but what if your files are permanently deleted—beyond the Recycle Bin? For that, Microsoft offers a command-line tool called Windows File Recovery, available for free from the Microsoft Store.
Windows File Recovery is a data recovery solution capable of recovering permanently deleted files from all local storage devices with NTFS, FAT, exFAT, and ReFS file systems, and you can read more about it in this review.
To recover permanently deleted files with Windows File Recovery:
- Install Windows File Recovery from the Microsoft Store.
- Launch the Command Prompt (CMD).
- Enter the following command (replace DRIVE_LETTER with the letter of the drive where your deleted files were located, and C: with the drive where you want to save recovered files) and press Enter: winfr DRIVE_LETTER: C: /x
- Wait for Windows File Recovery to finish scanning your USB flash drive and recovering permanently deleted data from it.
- Open File Explorer and navigate to the destination folder.
Because Windows File Recovery is still in its infancy, it can recover only a handful of common file formats, and it doesn’t exactly deliver the best data recovery results, especially when compared with mature data recovery applications like Disk Drill. Still, the tool is completely free, so it’s worth giving it a try.
Method 5: TestDisk
Best for: Recovering lost partitions.
TestDisk is an open-source data recovery tool that runs in the command line, where it provides a simple but interactive interface that makes it reasonably easy to recover USB flash drives that appear blank, raw, or unformatted due to partition table issues.
Indeed, its key feature is the ability to quickly locate and recover partitions that were deleted or corrupted from all USB flash drives recognized by the Windows operating system.
Follow these steps to recover a lost partition from your USB flash drive:
- Download TestDisk from the official website and extract the files.
- Launch testdisk_win.exe as administrator from the TeskDisk folder.
- Select Create when asked about log file creation.
- Choose your USB drive from the list and press Enter.
- Select your partition table type (usually “Intel” for USB drives).
- Choose Analyse and press Enter to start scanning for lost partitions.
- After the scan completes, press P to list files in any found partitions.
- If the files are found, select Write to save the recovered partition table.
If TestDisk reports that your USB drive’s file system is severely damaged, you may want to try PhotoRec (included with TestDisk) instead. PhotoRec can recover files even when the file system is beyond repair by scanning the drive’s raw data.
Alternative to CMD USB Flash Drive Recovery: Disk Drill
CMD recovery tools are handy in many situations, but they often leave a lot to be desired when dealing with complex data loss situations. If you’re looking for a more comprehensive, user-friendly option with better recovery success rates, Disk Drill is an excellent alternative that I can recommend based on my extensive personal experience with it.
Disk Drill offers several advantages over CMD recovery tools, starting with its intuitive interface that makes data recovery accessible even to those who fear the command line and data recovery in general.
However, the real star of the show are Disk Drill’s impressive USB flash drive recovery capabilities:
- The tool supports all file systems Windows users typically rely on when it comes to USB flash drives, including FAT, FAT32, exFAT, and NTFS.
- It performs recovery using both the existing file system (ideal when file system structures are intact) and file signatures (which scans the raw data for file signatures, perfect for recovering lost or corrupted files when the file system is damaged).
- It supports around 400 different file formats, including all the common types found on USB flash drives, such as documents (.docx, .pdf, .txt), images (.jpg, .png, .gif), videos (.mp4, .mov, .avi), and audio files (.mp3, .wav).
The USB flash drive recovery process involves just five simple steps when you use Disk Drill:
- Download Disk Drill from its official website and install it on your computer (not on the USB drive you’re trying to recover). Once installed, launch it either from the Start menu or using its desktop icon.
- Select your USB flash drive from the list of available storage devices listed on the main screen and click the Search for lost data button. Disk Drill will begin scanning the drive to find recoverable files. You can pause the scan at any time or simply let it run to completion for the best results.
- Once the scan is complete, Disk Drill will display a list of recoverable files. You can filter the results by file type or search by file name to make finding your lost files easier. Select the files you want to recover by clicking on the checkboxes next to them. You can preview many file formats directly in Disk Drill to verify that you’ve selected the right files and that they are recoverable.
- Click the Recover button and choose a directory where the recovered files will be saved. To prevent overwriting any data on the flash drive, select a location on your computer or a different external storage device.
- Confirm to move the selected files to the specified recovery location. When the recovery is done, open the recovery directory you specified and check if your files are all there. You should now have access to all the recovered data, and you can restore it to your USB flash drive or another device as needed.
You can use the free version of Disk Drill to recover up to 500 MB for free from your USB flash drive, which might just be enough to let you retrieve everything you need. To recover more than 500 MB, you’ll need to upgrade to Disk Drill PRO.
Conclusion
Command-line recovery tools in Windows are useful for many basic and even some more specific USB flash drive data recovery scenarios. That said, there are many other tools you can keep in your data recovery toolbox, including user-friendly solutions capable of delivering professional-grade results like Disk Drill. No matter what recovery tool you choose, the most important thing is to act quickly and avoid overwriting your lost data by not using the affected USB flash drive until the recovery process is complete.