The Gen 8.5/8.6 Toolset (toolset.bat.* files) and the Build Tool scripts will setup the required Visual Studio Environment variables using "%Gen8x%\Gen\GENENV.BAT".
Up to and including Visual Studio 2015 (version 140) the script "%VSnnnCOMNTOOLS%\vsvars32.bat" is invoked where nnn is the Visual Studio version.
The vsvars32.bat file executes VCVarsQueryRegistry.bat which contains the "reg" command to query the registry for VS directory locations.
In certain situations, an error may occur like the following: "Cannot determine the location of the VS Common Tools folder"
Verify that the User ID used to start the Gen Toolset has the authority to run Microsoft's "reg" command.
Verify the PATH does not have a problem or typo where the reg command cannot be located in the C:\Windows\System32 directory.
For Gen 8.6 supported Visual Studio 2017 (version 150) and 2019 (version 160), those versions have changed structure and "%Gen86%\Gen\GENENV.BAT" calls "%VSnnCOMNTOOLS%\VsDevCmd.bat" which does not use VCVarsQueryRegistry.bat. So the problem is not likely to occur with those versions.