How to Remove an Infected File Manually
In this article
Yes, you can manually remove an infected file from your computer by identifying the file, isolating it, and deleting it using built-in system tools. This process stops malware from running, but only works if you know the exact file and can access it safely without triggering further infection.
What You'll Need
- Administrative access to your computer
- Antivirus or anti-malware software (optional but recommended)
- Task Manager (Windows) or Activity Monitor (macOS)
- File Explorer or Finder
- Command Prompt or Terminal (for advanced steps)
Step-by-Step
- Disconnect from the internet. Unplug the Ethernet cable or turn off Wi-Fi to prevent the infected file from spreading or sending data.
- Open Task Manager on Windows (Ctrl+Shift+Esc) or Activity Monitor on macOS (found in Applications > Utilities). Look for suspicious processes using high CPU or memory. Note the process name and location.
- Right-click the suspicious process and select "End Task" (Windows) or "Stop" (macOS). Do not terminate system-critical processes like "System", "svchost.exe", or "kernel_task".
- Navigate to the file location shown in the process details. In Task Manager, right-click the process and choose "Open File Location" if available. On macOS, right-click in Activity Monitor and choose "Inspect" or "Reveal in Finder".
- If the file location opens, locate the suspicious executable (often .exe, .dll, .scr, .bat, or .js on Windows; .app, .plist, or shell scripts on macOS). Right-click it and select "Delete".
- If the file is locked or in use, reboot the computer in Safe Mode. On Windows, press Shift while clicking Restart, then go to Troubleshoot > Advanced Options > Startup Settings > Restart, and select Safe Mode. On macOS, restart and hold Shift until the Apple logo appears.
- Once in Safe Mode, repeat steps 2–5. The malware may not load, allowing you to delete the file.
- Empty the Recycle Bin (Windows) or Trash (macOS) permanently. Right-click and choose "Empty Recycle Bin" or use Terminal command
rm -rf ~/.Trash/*if needed. - Run a full system scan using your installed antivirus software. If none is present, download one from a clean device and transfer via USB, or use built-in tools like Windows Security (Windows) or Malware Removal Tool (macOS).
- Check startup programs. On Windows, open Task Manager > Startup tab and disable suspicious entries. On macOS, go to System Settings > General > Login Items and remove unknown apps.
Common Mistakes
People often delete the wrong file by misreading process names. For example, "svchost.exe" is legitimate, but "svch0st.exe" may be malicious. Always verify file paths and digital signatures. Another mistake is skipping Safe Mode, which can leave the file active and undeletable. Some users also forget to disable startup entries, allowing reinfection on reboot. Avoid using third-party deletion tools unless from trusted vendors, as they may bundle malware.
Tips
Before deleting any file, research its name online to confirm it’s malicious. Use reputable sources like Microsoft’s process library or VirusTotal. If the file is in a system folder like C:\Windows\System32, do not delete it unless confirmed infected—many malware mimic system files. Use the command line to delete stubborn files: in Command Prompt (as admin), use del /f "C:\path\to\file.exe". On macOS, use sudo rm -f /path/to/file in Terminal. Always back up important data before starting.
Troubleshooting
If you cannot delete the file, it may be protected by the system or locked by another process. Use Process Explorer (Windows) to see which process is using it, then end that process first. If the file reappears after deletion, it may be part of a larger infection. Run a full antivirus scan and check for rootkits using dedicated tools. If Safe Mode doesn’t load, the malware may have modified boot settings. Use a bootable antivirus USB drive to scan and remove the file from outside the OS. If the system becomes unstable after deletion, restore from a clean backup or use System Restore (Windows) or Time Machine (macOS).
Frequently Asked Questions
Can I remove a virus just by deleting the file?
Deleting the infected file stops that component, but malware often has multiple parts. Always run a full scan afterward to catch leftovers.
What if I accidentally delete a system file?
Restoring from a system restore point or reinstalling the OS may be needed. Avoid deleting files in system directories unless certain they’re malicious.
Is Safe Mode necessary?
Yes, if the file runs at startup. Safe Mode prevents most third-party apps from loading, making removal safer.
Can I use Command Prompt to delete locked files?
Yes. Open Command Prompt as administrator and use the del command with the full path. Use taskkill first to stop the process.
What do I do if the file won’t delete even in Safe Mode?
Use a bootable antivirus tool like Windows Defender Offline or Kaspersky Rescue Disk to remove the file before the OS loads.
Should I format the drive if I can’t remove it?
Only as a last resort. Back up clean files first, then reinstall the OS. Formatting erases everything and is not always necessary.