If you activate files which contain viruses, they will infect the system. Thus, most anti-virus programs including Windows Defender wouldn’t allow opening a file or executing any associated program if they suspect the file/program could trigger a virus attack. In such a case, you would encounter the error – Operation did not complete successfully because the file contains a virus.
It is possible that this message can occur even for known programs. In this case, it could be a false alarm. Anti-virus software products treat every unverified external file as a threat. So let’s have a look at possible solutions to fix it.
Operation did not complete successfully because the file contains a virus
If you are sure that the file/program in question is genuine, you could proceed with the following solutions get pass that error and execute the operation:
- Disable Windows Defender Antivirus/Third-party Antivirus Program temporarily
- Add an exclusion in Windows Defender/Third-party Antivirus Program
- Repair File Explorer
- Run Disk Cleanup Tool.
I wrote this post assuming Windows Defender as the default antivirus solution. Implement solutions suitably for your default anti-virus program.
1] Disable Windows Defender/Third-party Antivirus Program
While this error could occur with any anti-virus program as the default, it is more common with Windows Defender. To bypass the error, you could disable Windows Defender temporarily after judging the risks.
Click on the Start button and go to Settings > Updates and Security > Windows Security. Select Open Windows Security from the right-pane.
Now click on Virus and threat protection.
Under Virus and threat protection settings, click on Manage settings.
Turn the switch OFF for both Real-time protection and Cloud-delivered protection.
Restart the system and try executing the program.
2] Add an exclusion in Windows Defender/Third-party Antivirus Program
Disabling antivirus is a temporary solution. Once you are sure of the program, you should add the program or executable to the exclusion list.
Go to the Manage settings page for Windows Defender as explained above. Scroll down to Exclusion and click on Add or remove exclusions.
Select Add an exclusion and add the file/folder to the exclusion.
Try running the file/program after adding the exclusion and check if it works.
Once you have run the file successfully, make sure to turn on your anti-virus.
3] Repair File Explorer
In case the problem is with a file you tried accessing the File Explorer, or the problem occurs when using the File Explorer itself, you could try the following SFC command to repair a single file.
Search for Command Prompt in the Windows search bar. Right-click on the option and select Run as administrator. Type the following command sequentially and press Enter after each command:
If these commands resolve the problem, you will get the success message “Windows Resource Protection found corrupt files and successfully repaired them.” Restart the system.
This SFC option scans and repairs the file located at the specified full path. In our case, we tried fixing the File Explorer itself.
4] Run Disk Cleanup Tool
Many reports in forums suggest that some temporary files cause this error too. This could be resolved by running the Disk Cleanup Tool.
We hope one of these fixes made sure that your program ran. Let us know in the comments.