Redirecting command-line output to keep error messages from showing in the command window

后端 未结 3 1928
孤独总比滥情好
孤独总比滥情好 2021-01-16 10:29

I\'m testing the existence of a folder, and, depending on its existence, I want to run different commands:

DIR %MYDIR%\\tmp > test.txt
IF ERRORLEVEL 1 (
          


        
3条回答
  •  被撕碎了的回忆
    2021-01-16 10:57

    Use exist instead:

    @echo off
    if exist %MYDIR%\tmp (
      dir %MYDIR%\tmp > test.txt
      goto EndIt
    )
    echo %MYDIR%\tmp not found > test.txt
    :EndIt
    

提交回复
热议问题