Exception: Failed to locate env variables VS140COMNTOOLS or VS120COMNTOOLS
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd\ext
VS2017 has reworked its directory structure and filenames. The file is no longer titled "VsVars32.bat", you should look for the file 'vcvars.bat', which can be located in ..\Program Files (x86)\Microsoft Visual Studio\2017\EDITION\Common7\Tools\vsdevcmd\ext\vcvars.bat (using Adam's syntax, replace EDITION with the version of Visual Studio you use).
For simplicity, you can use %VSAPPIDDIR% in your call to point to the IDE folder where devenv.exe is located, and go back one folder to define your path to the batch file. For example: