How to Check for Viruses Using CMD in Windows (Complete Guide)
Viruses and malware can cause several problems on a Windows computer. You might notice that your PC is running slowly, unfamiliar programs are opening automatically, files are disappearing, or unexpected pop-ups are appearing while browsing the internet. These issues do not always mean your computer has a virus, but they are worth investigating.
Windows includes several command-line tools that can help you investigate suspicious files, check running processes, and scan your system for malware.
Command Prompt (CMD) is one of the easiest ways to access these tools. You can use commands to check Windows Defender status, start an antivirus scan, inspect suspicious processes, and identify unusual files.
In this guide, I’ll explain how to check for viruses using CMD in Windows 11 and Windows 10.
How to Check for Viruses Using CMD in Windows

To check for viruses using CMD in Windows, open Command Prompt as an administrator, check Windows Defender’s protection status, and run a Microsoft Defender antivirus scan. You can also use commands such as tasklist, netstat, and attrib to investigate suspicious processes, network connections, and hidden files.
Here’s how to do it step by step.
Step 1: Open Command Prompt as an Administrator
Before running antivirus commands, you need to open Command Prompt with administrator privileges. Some Windows security commands require permission to access protected system areas.
Here’s how to open it.
- Click the Start button on your Windows taskbar.
- Type CMD or Command Prompt in the search box.
- Find Command Prompt in the search results.
- Right-click it and select Run as administrator.
- If Windows displays a User Account Control (UAC) prompt, click Yes.
A black Command Prompt window will appear. You can now enter commands to check your computer.
Make sure you open the administrator version. Otherwise, some commands may display an access-denied message or fail to perform the requested operation.
Step 2: Check Whether Microsoft Defender Is Active
Windows 10 and Windows 11 include Microsoft Defender Antivirus, which provides real-time protection against viruses, spyware, ransomware, and other threats.
You can check its protection status using PowerShell commands through CMD.
In the administrator Command Prompt window, enter:
powershell -Command “Get-MpComputerStatus”
Press Enter.
Windows will display several security details related to Microsoft Defender.
Pay attention to these entries:
- AntivirusEnabled: Indicates whether antivirus protection is enabled.
- RealTimeProtectionEnabled: Shows whether real-time protection is active.
- AntivirusSignatureLastUpdated: Displays when the antivirus definitions were last updated.
- AntivirusSignatureVersion: Shows the currently installed antivirus definition version.
If AntivirusEnabled and RealTimeProtectionEnabled show True, Microsoft Defender’s corresponding protection features are active.
If they show False, investigate your Windows Security settings. Another antivirus application, organizational policy, or security configuration may affect these settings.
Step 3: Update Virus Definitions Before Scanning
Before checking your PC for viruses, make sure Microsoft Defender has the latest security intelligence.
Older virus definitions may not recognize recently discovered threats. Updating them helps Defender identify newer malware.
In Command Prompt, type the following command:
powershell -Command “Update-MpSignature”
Press Enter and wait for the update process to finish.
This command asks Microsoft Defender to download and install available security intelligence updates.
If the update succeeds, Defender will have newer threat definitions available for scanning.
If you receive an error, check your internet connection and make sure Microsoft Defender is available and not restricted by another security application.
Step 4: Run a Quick Virus Scan Using CMD
Now that your antivirus definitions are updated, it’s time to scan your computer.
A Quick Scan checks common locations where malware typically starts or operates, including areas associated with running processes and system activity.
Enter this command:
powershell -Command “Start-MpScan -ScanType QuickScan”
Press Enter.
Microsoft Defender will begin scanning your computer.
Depending on your PC’s performance and the number of files being checked, the scan may take a few minutes.
During the scan, avoid closing the Command Prompt window or interrupting the process.
Once the scan finishes, Defender will report any detected threats and take action according to your configured protection settings.
Remember that a quick scan is useful for an initial check, but it does not examine every file on your computer.
Step 5: Perform a Full Virus Scan
If you suspect your computer has malware, a Full Scan is a better option.
Unlike a quick scan, a full scan checks files and running programs across your system. It can take considerably longer, especially if your computer has multiple drives or a large amount of stored data.
Open Command Prompt as an administrator and enter:
powershell -Command “Start-MpScan -ScanType FullScan”
Press Enter to start the scan.
Now, let Microsoft Defender examine your computer.
Depending on your storage capacity and the number of files, the process could take several hours.
You can continue using your PC during the scan, but intensive activities may slow down the scanning process.
If Defender identifies malware, review its detection details and follow the recommended removal or quarantine action.
Step 6: Check Suspicious Running Processes
Sometimes, malware runs silently in the background without displaying a visible window.
You can use the tasklist command to see which programs and processes are currently running on your computer.
In CMD, type:
tasklist
Press Enter.
Windows will display a list of running processes along with their process IDs and memory usage.
Look for unfamiliar process names or applications that you don’t recognize.
However, don’t assume that an unfamiliar process is a virus. Many legitimate Windows services and third-party applications run in the background.
If you find something suspicious, you can search for its name online or check its file location using Task Manager.
To display additional process information, use:
tasklist /v
This command provides more details about running processes, including window titles when available.
Important: Never delete or terminate a Windows process simply because its name looks unfamiliar. Doing so could affect normal system operations.
Step 7: Check Suspicious Network Connections
Some malware communicates with remote servers to transfer information or receive instructions.
You can use the netstat command to inspect active network connections on your Windows computer.
Enter the following command:
netstat -ano
Press Enter.
You’ll see information about active network connections, including:
Proto: The network protocol being used, such as TCP or UDP.
Local Address: Your computer’s local network address and port.
Foreign Address: The remote address involved in the connection.
State: The current connection status, such as ESTABLISHED or LISTENING.
PID: The process ID associated with the connection.
If you notice an unfamiliar connection, note its PID and compare it with the running processes.
For example, use:
tasklist /fi “PID eq 1234”
Replace 1234 with the actual PID you found.
This helps you identify which program is associated with that connection.
Keep in mind that unfamiliar network connections are not automatically malicious. Browsers, Windows services, and legitimate applications regularly communicate with remote servers.
Step 8: Find Hidden or Suspicious Files
Some malware attempts to hide files by changing their file attributes.
You can use the attrib command to inspect hidden files and folders.
For example, to list hidden files in the C drive, enter:
dir C:\ /a:h
This command displays files and folders marked as hidden in the root directory of your C drive.
You can also inspect hidden and system files together:
dir C:\ /a
Look for unfamiliar file names or unusual locations, but don’t delete anything immediately.
Windows uses hidden and system attributes for legitimate files. Malware can also use these attributes, so the presence of a hidden file alone does not prove an infection.
If you identify a suspicious file, scan it with Microsoft Defender before taking further action.
Step 9: Check Microsoft Defender’s Threat History
After completing a virus scan, you should check whether Windows Defender detected anything.
Enter the following command in CMD:
powershell -Command “Get-MpThreatDetection”
Press Enter.
If Microsoft Defender has recorded threat detections, this command can display information about them.
You can also check the current threat records using:
powershell -Command “Get-MpThreat”
These commands help you review detected threats and related information.
If the results are empty, it may mean there are no recorded detections available through that command. It does not guarantee that your computer is completely virus-free.
For a more user-friendly view, open Windows Security, select Virus & threat protection, and click Protection history.
Here, you can review detected threats, quarantined items, and actions taken by Microsoft Defender.
FAQs
1. Can I check for viruses using CMD without antivirus software?
You can use CMD to inspect running processes, network connections, and suspicious files without installing another antivirus application. However, actual malware detection and removal require a capable security tool. Windows includes Microsoft Defender Antivirus for this purpose.
2. What is the CMD command to scan for viruses?
You can use this command to start a quick Microsoft Defender scan:
powershell -Command “Start-MpScan -ScanType QuickScan”
For a full system scan, replace QuickScan with FullScan.
3. How do I remove a virus using CMD?
You can start a Microsoft Defender scan through CMD to detect and handle malware. For example:
powershell -Command “Start-MpScan -ScanType FullScan”
Defender will handle detected threats according to its configured protection settings. You can review the results in Windows Security under Protection history.
4. Does CMD show whether my computer has a virus?
CMD can help you investigate suspicious processes, hidden files, and network connections. However, it cannot independently confirm that your computer is infected. Use Microsoft Defender or another trusted antivirus application for a proper malware scan.
5. Is Microsoft Defender enough to protect Windows 11 and Windows 10?
Microsoft Defender provides essential antivirus protection, including real-time monitoring and malware detection. For most users, keeping it updated and enabling its recommended security settings provides a good starting point for protecting Windows.
Summary
Checking your computer for viruses using CMD is easier than it might seem. You can use Command Prompt to access Microsoft Defender, update virus definitions, run quick and full scans, inspect running processes, and investigate suspicious network connections.
For beginners, I recommend starting with a Microsoft Defender Quick Scan.
If you still suspect malware, perform a Full Scan and review the Protection History in Windows Security.
