Permission Denied building CPP file in Visual Studio Code

When I run the below given code on visual Studio Code, first Building it, but it shows:

> Executing task: g++ -g main.cpp <

d:/software/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot open output file a.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
The terminal process "C:\Program Files\Git\bin\bash.exe '-c', 'g++ -g main.cpp'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

I have Bitdefender Antivirus on the system. It showed an error describing "Infected File Detected", it detected a .exe file and after that I removed it from quarantine and deleted the file from there in the Bitdefender software but now I am not able to run CPP file.

#include <iostream>
using namespace std;
class Aclass
{
public:
    int x = 0, y = 0;
    Aclass() { cout << "constructor of Aclass" << endl; }
}
int main () {
    Aclass b;
}

I tried some solutions from stack and other forums but didn't work, though other forums there is nothing much but on stack I found one with solution to turn ON "Application Experience", but unfortunately I cant find it on services.msc

Any help will be much appreciated. Thank You.

Comments

  • I got my answer so I thought It would be share with other member too. I was also facing this same problem. To solve it you should open Bitdefender, then go to Exclusions setting, select Add a folder, and then navigate to your MINGW folder installation. Note that you have to select the entire MINGW folder, and then save it. Restart your system and then Visual Studio Code will not show this error.

  • To solve it you should open Bitdefender, then go to Exclusions setting, select Add a folder, and then navigate to your MINGW folder installation. Note that you have to select the entire MINGW folder, and then save it. Restart your system and then Visual Studio Code will not show this error. or go to the DMVNow.com