I have batch file that sets user path and is run as part of Visual Studio IDE build step.
@ECHO OFF
@ECHO %PATH%
set COMSPEC = \"%VCINSTALLDIR%\\vcvarsall.ba
That what Setx does. See Setx /?
where it tells you this. It adds it to the user's environment permanently (unless /m is used). However %PATH% is built from system and user environment's PATH (and also autoexec.bat on 32 bit windows and if started through ShellExecute also App Paths reg key))
Don't worry about. Setx doesn't add paths to %PATH% if they already exist in %PATH%.
Why are you redefining the system variable %COMSPEC%.