# 查看环境变量 wmic environment where "name='Path'" get UserName,VariableValue
# 删除环境变量 wmic ENVIRONMENT where "name='PPTV_HOME'" delete
举个例子
1 2 3 4 5 6 7 8 9 10
REM 设置一下需要添加环境变量的目录 SET DestFile="%USERPROFILE%\bin" REM 增加bin环境变量 setpath | findstr "%DestFile%" >nul && ( echo 环境变量已存在 ) || ( echo 环境变量不存在 wmic ENVIRONMENT where "name='Path' and username='%USERDOMAIN%\\%USERNAME%'" set VariableValue="%Path%;%DestFile%" )