


how to fix 'operation did not complete successfully because the file contains a virus' win defender error
Aug 03, 2025 am 02:20 AMFirst, confirm whether it is a false positive and use tools such as VirusTotal to detect file security; 2. If you are sure that the file is safe, you can temporarily close the real-time protection of Microsoft Defender; 3. It is recommended to add files or folders to the Defender exclusion list for a long time to resolve; 4. If the file has been quarantined, you can recover from the protection history; 5. Check and update the Defender virus definition; 6. Advanced users can try to extract files from the command line; finally be sure to verify that the file is safe before operating to avoid permanently closing the protection.
You're seeing the error “Operation did not complete successfully because the file contains a virus” in Windows Defender (Microsoft Defender Antivirus) when trying to access or extract a file. While this message usually means a file is generally infected, sometimes it's a false positive — especially when dealing with legitimate software, scripts, or self-created archives.

Here's how to fix or work around this issue:
? 1. Confirm It's a False Positive (Check the File)
Before bypassing security, make sure the file is safe .

- Scan the file with other antivirus tools :
- Upload it to VirusTotal.com — it checks your file against 70 antivirus engines.
- If only Microsoft Defender flags it and others don't, it's likely a false positive .
- If you created the file yourself (eg, a script, compiled program, or ZIP), and you're confident it's clean, proceeded cautiously.
?? Never ignore this warning for files from unknown or untrusted sources.
? 2. Temporarily Disable Microsoft Defender (Use with Caution)
If you're certain the file is safe, you can temporarily turn off real-time protection to access it.

Steps:
- Open Windows Security :
- Press
Win S
, type Windows Security , and open it.
- Press
- Go to Virus & threat protection .
- Click Manage settings under "Virus & threat protection settings".
- Toggle off Real-time protection .
- ? This is temporary — Windows may re-enable it automatically after 10–15 minutes, especially on Home editions.
- Now try opening or extracting the file.
- Re-enable Real-time protection immediately after.
? Note: Don't leave this off longer than necessary. It leaves your system vulnerable.
? 3. Add an Exclusion in Microsoft Defender
If you need to keep using the file regularly, add it (or its folder) to the exclusion list .
How to add an explanation:
- Open Windows Security > Virus & threat protection .
- Click Manage settings under "Virus & threat protection settings".
- Scroll down to Exclusions > Add or remove excclusions .
- Click Add an exclusion and choose:
- File (specific file)
- Folder (entire folder, eg, your project folder)
- File type (extension, eg,
.exe
) - Process
- Browse and select your file or folder.
Now, Defender will ignore it during scans.
? Tip: Use folder exclusions if you're working with development projects or scripts that get flagged often.
? 4. Restore the File from Quarantine (If Already Removed)
If Defender already deleted or quarantined the file:
- Open Windows Security .
- Go to Protection history (under "Virus & threat protection").
- Look for the file listed as "Quarantined".
- Select it and click Restore (and optionally Allow on device ).
?? Only restore if you're 100% sure it's safe.
? 5. Check for Outdated Defender Signatures
Sometimes outdated virus definitions cause incorrect behavior.
- Open Windows Security > Virus & threat protection .
- Under Virus & threat protection updates , click Check for updates .
- Update and then retest the file.
? 6. Use Command Line (For Advanced Users)
If GUI methods fail, you can extract ZIP files via command line — sometimes bypassing Defender during extraction (though Defender may still block access afterward).
mkdir output_folder tar -xf "C:\path\to\your\file.zip" -C output_folder
This uses built-in Windows tar
(available in Windows 10/11). If the file is blocked, even this may fail.
Final Notes
- Microsoft Defender is generally accurate — treat this error seriously.
- Developers and IT pros often face false positives with
.exe
,.ps1
,.bat
, or packed files. - Exclusions are the cleanest long-term fix for trusted files.
- Never disable Defender permanently — use excclusions instead.
Basically, it comes down to: verify safety → exclude or restore → re-enable protection .
Don't skip the verification step — your system's security depends on it.
The above is the detailed content of how to fix 'operation did not complete successfully because the file contains a virus' win defender error. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

When the Windows Security Center is blank or the function is missing, you can follow the following steps to check: 1. Confirm whether the system version supports full functions, some functions of the Home Edition are limited, and the Professional Edition and above are more complete; 2. Restart the SecurityHealthService service to ensure that its startup type is set to automatic; 3. Check and uninstall third-party security software that may conflict; 4. Run the sfc/scannow and DISM commands to repair system files; 5. Try to reset or reinstall the Windows Security Center application, and contact Microsoft support if necessary.

Encountering something went wrong 657rx can be frustrating when you log in to Microsoft Teams or Outlook. In this article on MiniTool, we will explore how to fix the Outlook/Microsoft Teams error 657rx so you can get your workflow back on track.Quick

When encountering the "RPCserverisunavailable" problem, first confirm whether it is a local service exception or a network configuration problem. 1. Check and start the RPC service to ensure that its startup type is automatic. If it cannot be started, check the event log; 2. Check the network connection and firewall settings, test the firewall to turn off the firewall, check DNS resolution and network connectivity; 3. Run the sfc/scannow and DISM commands to repair the system files; 4. Check the group policy and domain controller status in the domain environment, and contact the IT department to assist in the processing. Gradually check it in sequence to locate and solve the problem.

When you encounter the "DefaultGatewayisNotAvailable" prompt, it means that the computer cannot connect to the router or does not obtain the network address correctly. 1. First, restart the router and computer, wait for the router to fully start before trying to connect; 2. Check whether the IP address is set to automatically obtain, enter the network attribute to ensure that "Automatically obtain IP address" and "Automatically obtain DNS server address" are selected; 3. Run ipconfig/release and ipconfig/renew through the command prompt to release and re-acquire the IP address, and execute the netsh command to reset the network components if necessary; 4. Check the wireless network card driver, update or reinstall the driver to ensure that it works normally.

When encountering the "SYSTEM_SERVICE_EXCEPTION" blue screen error, you do not need to reinstall the system or replace the hardware immediately. You can follow the following steps to check: 1. Update or roll back hardware drivers such as graphics cards, especially recently updated drivers; 2. Uninstall third-party antivirus software or system tools, and use WindowsDefender or well-known brand products to replace them; 3. Run sfc/scannow and DISM commands as administrator to repair system files; 4. Check memory problems, restore the default frequency and re-plug and unplug the memory stick, and use Windows memory diagnostic tools to detect. In most cases, the driver and software problems can be solved first.

Windows 11 KB5062660 is now rolling out as an optional update for Windows 11 24H2 with a few new features, including Recall AI in Europe. This patch is available via Windows Update, but Microsoft has also posted direct download l

When the boot prompt is "Windows could not start because of the following fileismissing" 1. You can run bootrec/fixmb, bootrec/fixboot, bootrec/rebuildbcd through the Windows installation media; 2. Check the hard disk connection or use CrystalDiskInfo to detect the health status of the hard disk; 3. If there is a dual system, you can use the bootrec command to rebuild the boot or manually add the boot items; 4. Use PE environment to kill viruses and combine DISM and SFC tools to repair the system files, and the system can be restored in most cases.

If the second monitor is not recognized by Windows, first check whether the cable and interface are normal, try to replace the HDMI, DP or VGA cable, confirm the plug-in video output port, and test different interfaces to eliminate compatibility issues; then verify the monitor power and input source settings, and connect the monitor separately to test whether it can be recognized; then enter the Windows display settings and click the "Detection" button, or use Win P to switch the display mode, and update the graphics card driver at the same time; finally check the graphics card specifications to confirm whether it supports multi-screen output to avoid exceeding its maximum output capability.
