在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
貌似没有很优美的做法,只能把%Path%按分号分割,然后一段一段地比较。 :InPath [In]Path [Out]0/1 SETLOCAL SET LocalPathCopy=%PATH% SET Result=0 :WHILE IF "%LocalPathCopy" == "" GOTO WEND FOR /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 :InPathRet ENDLOCAL & SET %2=%Result% & GOTO :EOF 使用方法: SET x=C:\Windows Call :InPath %x% Result IF %Result% == 0 SET Path=%Path%;%x% |
请发表评论