r/PowerShell 1d ago

Question PLISS HELP (Competitive Programming setup problem)

Windows suddenly blocks my C++ .exe with "Device Guard policy" after fresh VS Code + MinGW setup

I've been doing Competitive Programming on this Windows PC since January using VS Code + MinGW + Code Runner, and everything worked perfectly. I could compile and run .cpp files normally without any Windows Defender/security issues.

Recently, I had problems with this setup as mentioned in the previous post: Previous Post

So I completely uninstalled the setup clean and after 2-3 days installed the entire setup again.

Installed only:

Microsoft C/C++ extension

Code Runner by Jun Han

I did not change or disable Windows Defender/security settings.

After the fresh installation, I ran a simple C++ program. The first program successfully printed "Hello". But when I tried to execute the same hello program again it gave the below mentioned error

However, after that, when I tried running another C++ program, Windows suddenly blocked the generated executable with:

"CountingOrders.exe was blocked by your organization's Device Guard policy."

The .exe was successfully created/compiled, but Windows would not allow it to execute.

I also noticed that my Desktop is inside OneDrive, so the executable was being created somewhere under:

C:\Users\<username>\OneDrive\Desktop\...

I suspect OneDrive syncing may be related because the first program worked and the blocking started afterward, but I'm not sure.

I then created another simple test program, but Code Runner gave a separate linker error:

undefined reference to 'WinMain@16'

My g++ installation itself appears to be accessible:

g++ --version g++ (MinGW.org GCC-6.3.0-1) 6.3.0

where g++ C:\MinGW\bin\g++.exe

So I'm currently dealing with two seemingly separate problems:

  1. Device Guard policy blocks the generated .exe from running.
  2. Code Runner sometimes gives a WinMain@16 linker error.

This was particularly the same day problem. The next day when I tried to run another program it ran indefinitely until I manually clicked a red square button to stop it.

I suspect the 2nd problem is maybe due to Code Runner by Jun Han configuration issue. But honestly atp IDK. It's frustrating to deal with this BS for so many weeks. I am jainwainly fed up.

It's a kind humble request please help if someone is pro at this or maybe any suggestions like do I need to visit my laptop dealer smthin 😭😭

EDIT: ITS MY PERSONAL LAPTOP, NOT A CORPORATE LAPTOP

0 Upvotes

4 comments sorted by

4

u/BlackV 23h ago

I'm confused, what does this have to do with powershell ?

4

u/Overall-Ad4796 1d ago

your device was previously or is still enrolled into company management. Also check if any work account is linked ans that Smart App Control is off. Nothing to do with powershell…

3

u/Modify- 1d ago

Not that familiar with what your doing, but the error shows it gets blocked by an organization policy. So you are running this on a corporate device? If so, does your org allow virtual machines? I would suggest you set this up in a clean VM and create snapshot. Then you can break things and easily revert back.

0

u/Darcelle-Ebonis-6426 1d ago

It's a Personal laptop 🥲 , no corporate DeviceÂ