How to set PATH environment variable in batch file only once on Windows?

后端 未结 2 1908
臣服心动
臣服心动 2020-11-28 16:10

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         


        
2条回答
  •  粉色の甜心
    2020-11-28 16:33

    1. 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))

    2. 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%.

提交回复
热议问题