I can compile my C++ source with g++ and produce main.exe, but running it from PowerShell sometimes fails with an error saying that an Application Control policy blocked the file. I already tried excluding the project folder from Windows Defender, but the executable is still blocked. What should I check or change?
3 Answers
This message usually comes from Windows Application Control rather than ordinary antivirus scanning. A Defender folder exclusion may not override an AppLocker, Smart App Control, or organization-managed policy. Check Windows Security and Event Viewer for the exact rule that blocked main.exe. If this is a school or work computer, an administrator may need to approve the compiler output or adjust the policy. On a personal computer, verify that the executable is really the one you just built and test from a normal local folder rather than a protected or synchronized directory.
The intermittent behavior can happen when the security tool evaluates newly created executables differently from previously trusted files. Avoid repeatedly disabling protection or downloading random replacement executables. Check the protection history and application-control logs, update the compiler from a trusted source, and ask the device administrator to whitelist the compiler/output if the machine is managed.
Make sure the build step succeeds before trying to run the program. In PowerShell, use `g++ main.cpp -o main.exe` and then run it with `./main.exe`. If compilation fails or produces the executable in another directory, PowerShell may be launching an older file. However, when the error specifically says an Application Control policy blocked the file, the main issue is Windows policy—not the C++ code.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures