24

I tried to run some C++ code on Visual Studio 2017, but I am getting this message shown below:

Access Denied

Unable to start program 'E:\wittos\company projects\project 4\object tracking\source codes\KCF-master (1)\KCF-master\x64\Release\ALL_BUILD'.

Access is denied.

How can I resolve this error?

0

9 Answers 9

23

It is because you didn't set start project you want. right click the project you want to debug, and then click set as StartUp Project. This will solve your problem.

3
  • In my case I have the right startup project selected and still have this issue.
    – Nmaster88
    Commented May 9 at 9:32
  • We had to do this even though the desired project was ALREADY set. Lost hours looking in the wrong place. Easy fix though, thank you :-)
    – EvilDr
    Commented May 15 at 9:55
  • Setting start up project have nothing to do with access denied Commented May 31 at 7:02
22

My culprit was my anti-virus software thinking my newly built .exe was malicious and quarantining it.

To fix it, go to Anti-virus -> Change Settings -> Real-Time scanning -> Excluded Files -> Add

Add your Debug and Release targets.

0
19

You are trying to "execute" the "ALL_BUILD" folder rather than your program; a folder can't be executed.

Check your program's project properties and ensure that the "Command" you want to debug actually points to the compiled 'exe' file or $(TargetPath) and ensure that you have the correct start-up project selected.

2
  • I sometimes get this error for attempting to execute a specific .exe file so this doesn't seem like the root issue. Rather the last fragment of your answer, "ensure that you have the correct start-up project selected." is the root cause of the issue, but it doesn't specify how to set a project as the correct start-up project.
    – TylerH
    Commented Mar 28 at 14:12
  • I have the same issue and this doesn't seem to help.
    – Nmaster88
    Commented May 9 at 9:29
2

Having had the same problem, only thing that fixed it for me was to add my source folder to the Excluded Folders from Windows Defender Threat Protection (in Win10 security settings).

1
  • 1
    How this is not the most voted and accepted answer is out of my mind.
    – Nmaster88
    Commented May 9 at 9:38
2

On Windows 11 there is something called controlled folder access. Disable it or allow the program. Enable system notifications and build again. You will receive a notification of unauthorized access. Allow it from there and it will work.

Alternatively, run this PowerShell command:

Add-MpPreference -AttackSurfaceReductionOnlyExclusions "<fully qualified path or resource>"
1
  • This solved the problem for me. Commented Aug 13 at 10:28
0

If you are using a machine managed by your organization and don't have privileged access to disable the anti-virus they use, there is an option to exclude your project from being scanned.

Please refer to the below article - Fix 6

0

I have a dual boot computer (Linux Debian 11 and Windows 10). Inside Debian, on my NTFS D disk, I created a folder to perform programming tests.

After accessing that folder with Windows, I created a new project in Visual Studio inside that same folder that I had created in Linux. Even going straight to the folder where the application's executable was and clicking directly on it, I still received the access denied error message. I took the project out of the folder I had created in Linux, and it worked.

Because the folder where my project was was created in Linux, for some reason, Windows didn't trust this folder, so it didn't allow running executables from inside that folder, even with this one executable having been created by Visual Studio from within Windows.

-1

This happens due to permissions issue in your machine.

so get permissions added . in my case due to time crunch i just relocated my project to visual studio projects path and that worked correctly.

example Path for VS2019

C:\Users\UserName\source\repos\YourProject

-1

Yes, stop antivirus realscan while debugging. I experienced this with Mcafee after long investigation

2
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Mar 30, 2023 at 16:07
  • This is a duplicate answer. Before posting make sure you check to see if someone else has already provided the same solution. - From Review
    – Nol4635
    Commented Apr 1, 2023 at 18:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.