0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

バッチファイルでプロンプト表示&ログ出力

0
Last updated at Posted at 2022-02-16
  • 思い出すのに苦労するのでメモ
  • 標準出力&エラー出力をコマンドプロンプト&ログ出力する方法

サンプル

hoge.bat
@ECHO OFF

REM カレントディレクトリへ移動
cd /d %~dp

REM コマンド実行
FOR /F "usebackq" %%i IN (`dir /b 2^>^&1`) DO (
    REM 遅延環境変数を避けるためにサブルーチンへ移動
    call :result %%i !ERRORLEVEL!
)

REM 終了
pause
exit /b o

REM プロンプト出力 & ファイル出力
:result
    echo 
    echo %~1 >> C:\hoge.txt
    
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?