貌似没有很优美的做法,只能把%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%
如对本文有疑问, 点击进行留言回复!!
BAT批处理判断服务是否正常运行的方法(批处理命令综合应用)
网友评论