批处理中我想判断电脑上已有的python版本是不是36,但是findstr一直无法判断“36”是否存在里面,总是返回不存在
代码:
for /f "delims=" %%b in ('dir /s /a-d /b python.exe 2^>nul') do (
if exist "%%b" (
echo %%b
set s=%%~pb
echo %s%|findstr "36" >nul
echo %errorlevel%
::call set a=%%s:~-9,-1%%
call echo %%s:~-9,-1%%, detected in your computer
call:inpu
pause
exit
)
)
执行结果
C:\Program Files\Python36\python.exe
0
Python36, detected in your computer