0
1

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 1 year has passed since last update.

batch使ってファイル中の文字列を全部取り出して変数に渡す

Last updated at Posted at 2022-07-13
rem *****バッチ実行
java -cp some command 2>exception.log
rem エラー時はエラー処理へ
IF ERRORLEVEL 1 goto ABEND
rem 成功処理
省略...
exit /b 0


rem エラー処理
:ABEND
setlocal enabledelayedexpansion
rem ファイル中の文字列を全部を取り出す
set text=
rem tokens=* 行ごとにループ、text変数にわたす
for /f "tokens=*" %%i IN (exception.log) do set text=!text!%%i
rem エラー文字列をイベントビュアーに登録
eventcreate /ID 999 /L Application /T ERROR /D "%text%"
endlocal
rem *****異常終了(コード=1)
exit /b 1

eventcreate について

eventcreate (Computer) /ID EventID (option) /T Type /D Description

登録内容確認
image.png

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?