Open In App

“Access is Denied error” in C++ Visual Studio and How to resolve it

Improve
Improve
Like Article
Like
Save
Share
Report

Pre-requisite: How to Install Visual C++ on Windows

In this article, we will discuss about access denied error in Visual Studio in C++.

What is Access denied error in Visual Studio in C++?

Access denied error in Visual Studio in C++ occurs when there is an attempt to access one of the installation files and due to some reason the access is denied to the requested file. There can be several reasons for it. This article focusses on discussing the access denied error encountered while running a C++ program in Visual Studio.

Why does Access denied error occurs?

The access denied error occurs when Visual Studio is unable to access one or more installation files. This error can occur due to one of the following reasons:

  1. An outside process like an antivirus or anti-malware application has locked a Visual Studio installation file while Visual Studio was installing the files at the time of the installation. 
  2. The user installing the Visual Studio does not have administrative privileges to successfully install all the files. To install Visual Studio, the user must be Admin and must start the installer by right clicking and select Run as Administrator option.
  3. Permissions on some registry or hives can prevent Visual Studio from installing all the files.

How to resolve this error

One of the solution to resolve the error is to make changes in the anti-virus software to unlock the Visual Studio installation file. Below is the screenshot of the error encountered while running a C++ program in Visual Studio.

Access Denied Error

Error message

There are various methods to install VS Code and MinGW(C compiler) but when these are used to run a code it may show some error in output or in VS code terminal. But it might not be the case that the installation process is incorrect. It’s because of the system’s anti-virus that is blocking the VS code to get access to the MinGW’s bin folder. 

Steps to resolve the error:
Below are the steps to resolve the error in McAfee anti-virus software.

Step 1: Open McAfee antivirus application.

McAfee antivirus application

Step 2: Find the settings option then click on it.
Step 3: Click on the Real-Time Scanning option. Here one can find more options.

Real-Time scanning

Step 3: The last step is to click on the Turn Off button and turn it off as long as you want. This option will turn off the real-time scanning.

Turn off real-time scanning

With these simple steps one can easily turn on and off the anti-virus and will not face problems anymore. Also there is option to exclude some individual files from the scan by adding them to the exclude files section and the anti-virus scan will skip that particular folder while performing the computer scan.

EDIT : If you have trouble downloading/installing MinGW-64, it might be due to the mirror server used by the installer.

Error message

You can download the file directly and extract it to your PC without using the installer.
Download and decompressing program such as 7-zip at https://www.7-zip.org/
Then download the specific MinGW-64 version for your PC at: https://sourceforge.net/projects/mingw-w64/files/
See the image below for the link:

SourceForge website

Once downloaded, extract the .7z file onto your PC using 7-zip and extract to a folder such as C:\MinGW64
You don’t have to put it in ‘Program Files’ like the installer does.
Once extracted, set the Windows PATH environment variable and you should be in business.


Last Updated : 01 Dec, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads