bat获得环境变量属性值的第一段 博客分类: JAVA
程序员文章站
2024-03-09 17:39:05
...
分号将Path中的路径分隔开,取第一个路径用tokens=1,第2个tokens=2,以此类推
for /f "tokens=2 delims=;" %%a in ("%path%") do set NewPATH=%%a
@echo off
FOR /F "tokens=1,2* delims=;" %%a in ("%path%") do set newPATH=%%b
echo newPATH=%newPATH%
实际应用:
echo off
FOR /F "tokens=1,2* delims=;" %%a in ("%ALMS_PATH%") do set newPATH=%%a
echo %newPATH%
输出:
8080@192.xxxx.xxx.xx
for /f "tokens=2 delims=;" %%a in ("%path%") do set NewPATH=%%a
@echo off
FOR /F "tokens=1,2* delims=;" %%a in ("%path%") do set newPATH=%%b
echo newPATH=%newPATH%
实际应用:
echo off
FOR /F "tokens=1,2* delims=;" %%a in ("%ALMS_PATH%") do set newPATH=%%a
echo %newPATH%
输出:
8080@192.xxxx.xxx.xx