The operating results displayed and saved to a file echo when using bat batch

The principle:

Because to be output to the text, you can use call outputs the results to a temporary file, do three things after the completion of:

1. The provisional text display, realize the function of this window shows the results of the run, you can clear the screen.

2. The provisional text is appended to the log file to save.

3. Delete temporary files.

 

@echo off
setlocal enabledelayedexpansion

if '%1'=='' (
  set /p ch=Input:
  call a.bat !ch! > log2.txt
  goto :end
) else (
  set ch=%1
  echo Input:!ch!
)

echo Your_choice=%ch%
goto :end

:end

if '%1'=='' (
    cls
    for /f "delims=" %%i in (log2.txt) do (
        echo %%i
    )
    type log2.txt >> log.txt
    del log2.txt
)

    

 

Guess you like

Origin www.cnblogs.com/qiyuexin/p/11701362.html