ljymoonlight

导航

bat for 命令讲执行结果返回给变量

bat 执行结果赋值命令

for /f "delims=" %%i in ('dir ') do set b=%%i

  • 直接讲dir 命令修改为任何需要执行的命令

`@echo off
echo %path%>tmp
set b=
::set TMP_STR=('findstr "CAT" tmp')
for /f "delims=" %%i in ('findstr "CAT" tmp') do (
set b=%%i
)

if "%b%" == "" (
echo "aaaaaaaaaaaaaa"
) else (
echo "abb"
)`

posted on 2021-10-10 18:43  ljymoonlight  阅读(1035)  评论(0编辑  收藏  举报