貌似没有很优美的做法,只能把%Path%按分号分割,然后一段一段地比较。
:InPath [In]Path [Out]0/1SETLOCALSET LocalPathCopy=%PATH%SET Result=0:WHILEIF "%LocalPathCopy" == "" GOTO WENDFOR /F "delims=;" %%I IN ("%LocalPathCopy%") DO ( IF /I "%%~I" == "%~1" ( SET Result=1 GOTO WEND ))FOR /F "delims=; tokens=1,*" %%I IN ("%LocalPathCopy%") DO ( SET LocalPathCopy=%%~J)GOTO WHILE :WEND :InPathRetENDLOCAL & SET %2=%Result% & GOTO :EOF |
使用方法:
SET x=C:/WindowsCall :InPath %x% ResultIF %Result% == 0 SET Path=%Path%;%x% |
新闻热点
疑难解答