attrib command with specific flags, you can strip these attributes and reveal your data without third-party software. This method targets the root cause of the visibility issue rather than just deleting suspicious items.
Understanding the Malware Behavior
When a computer becomes infected with certain types of viruses, particularly those that target removable drives or network shares, the malicious code often alters file attributes. Instead of deleting your documents, images, or videos, the virus renames them with random characters and sets their properties to "Hidden" and "System." In some cases, it creates empty folders with the same names as your original files to deceive users into thinking their data is gone. These dummy folders usually have zero kilobytes in size, while the actual hidden files remain intact but invisible in standard File Explorer views.
This technique is effective for attackers because most users do not know how to change folder options to show hidden items, let alone system-level hidden files. Even when standard hidden files are visible, the "System" attribute often remains checked, keeping the infected folders out of sight. Understanding this behavior is crucial before attempting recovery, as it confirms that your data likely still exists on the drive.
Preparing Your Environment
Before running any commands, it is essential to stop the virus from re-hiding your files. If the malicious process is active, it may immediately revert any changes you make. Therefore, start by disconnecting external drives or USB sticks from the infected machine. Do not open any folders on the drive, as this might trigger the virus to execute its hiding routine.
If you suspect an active infection on your main system drive, consider booting into Safe Mode. This prevents most startup programs and malware services from loading. Once in a clean environment, open the Command Prompt with administrator privileges. Right-click the Start button and select "Terminal (Admin)" or "Command Prompt (Admin)" depending on your Windows version. This elevated access is required to modify system-level file attributes.
Using the Attrib Command
The core tool for this recovery is the attrib utility built into Windows. This command allows you to view and change file attributes such as Read-only, Hidden, System, and Archive. To unhide all files and folders on a specific drive, you need to remove both the Hidden (-h) and System (-s) attributes.
Open the Command Prompt and type the following command, replacing X: with the letter of the affected drive:
attrib -h -s /s /d X:\*.*
Here is what each part of the command does: -h removes the hidden attribute, -s removes the system attribute, /s applies the command to all subdirectories, and /d ensures that directories themselves are also processed. The *.* wildcard selects every file and folder on the drive. Press Enter to execute. The process may take several minutes depending on the number of files present.
Once the command finishes, navigate to the drive in File Explorer. You should now see the original folders and files alongside the dummy zero-kb folders created by the virus. Identify the fake folders by their empty size and delete them. Keep your real files safe.
Verifying File Integrity
After unhiding the files, check if they open correctly. Some viruses may corrupt file headers during the renaming process. If files are inaccessible, you may need additional recovery steps. However, in most cases, simply removing the attributes restores full access. For further protection against similar threats, review our guide on How to Completely Remove a Virus from Your Desktop to ensure no residual malware remains active.
Preventing Future Incidents
To avoid this situation recurring, configure Windows to show protected operating system files only when necessary. Go to File Explorer Options, select the View tab, and uncheck "Hide protected operating system files (Recommended)." Be cautious when doing this, as it exposes critical system files to accidental deletion. Additionally, always scan removable media with updated antivirus software before opening them. If you frequently deal with deleted data issues, learning how to recover lost files is equally important, as detailed in How to Find Deleted Files in Drive C.
Frequently Asked Questions
Why are my files still hidden after running the attrib command?
This usually happens if the virus is actively running and re-applying the attributes. Ensure you have disconnected the drive or booted into Safe Mode to prevent the malware from interfering. Also, verify that you used the correct drive letter in the command.
Can I use this method on a Mac or Linux system?
No, the attrib command is specific to Windows. macOS uses chflags and Linux uses chmod or chattr to manage file permissions and visibility. The syntax and available flags differ significantly between these operating systems.
What if the virus renamed my files with extensions like .exe or .scr?
Malware sometimes disguises itself as executable files to trick users into running it. After unhiding files, check for any unexpected executables in your folders. Rename them back to their original formats (e.g., .docx, .jpg) if possible, or delete them if they are clearly malicious. Always scan the drive again after cleanup.
Is it safe to delete the zero-kb folders?
Yes, these folders are typically created by the virus as decoys. They contain no data and serve only to confuse the user. Deleting them is safe and helps keep your directory structure clean. Just double-check that you are deleting the empty folders and not your actual data.
Will this process delete any of my existing data?
Running the attrib command only changes file attributes; it does not delete or modify file contents. Your data remains intact. However, always maintain regular backups to protect against accidental errors or more severe malware infections that might corrupt files directly.