GenerateProjectFiles error - so frustrating

I have Visual Studio Community 2019 installed. When I run GenerateProjectFiles.bat (for Unreal 4.24) it says:

GenerateProjectFiles ERROR: Unable to find a valid installation of Visual Studio. Please check that you have Visual Studio 2017 or Visual Studio 2019 installed, and the MSBuild component is selected as part of your installation.

I have selected MSBuild as a component but it still won’t work. I think it might have something to do with the fact that I uninstalled Visual Studio from my C drive onto my D drive because I was running out of space. But the Unreal source is installed on the D drive as well, so I don’t know why it can’t see Visual Studio. Can somebody please help?

Look if this fixes it