Can only generate C++ files with 5.0.3, not 5.1.1 or 5.2

I am new to Unreal Engine and am trying to start a new C++ project in UE 5.2, but whenever I try I get the following error:

An error occurred while trying to generate project files.

Running C:/Program Files/Epic Games/UE_5.2/Engine/Build/BatchFiles/Build.bat -projectfiles -project=“C:/Users/name/GDrive/GD_Personal/GameDevelopment/Unreal_Projects/MyProject2/MyProject2.uproject” -game -rocket -progress

This happens with UE 5.1.1 as well, but C++ files are generated just fine on 5.0.3.

I am using Visual Studio 2022 and have followed the documentation here: Setting Up Visual Studio Development Environment for C++ Projects in Unreal Engine | Unreal Engine 5.2 Documentation

I have tried using Visual Studio 2019. I have tried uninstalling and reinstalling both Visual Studio and Unreal Engine.

I also cannot generate C++ files from within the editor of a blueprint project. I get the following message, then I click yes and the editor freezes:
image

Since no project files were generated there is nothing to recompile. I cannot open the project or regenerate project files.

The output log is too long to post and I am a new member so I cannot upload it.