2
4

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 5 years have passed since last update.

C#(.exe)からバッチに戻り値を渡す

2
Last updated at Posted at 2017-11-15

こんにちは。@mashiです。

Windows環境にて、バッチから.exe(C#)を起動し、戻り値をバッチに返す。ということをしようとしたのですが、いろんな書き方がありなかなか上手くいかなかったので、できた方法をメモ。

exec.bat
setlocal enabledelayedexpansion

IF !ERRORLEVEL!==[戻り値] (
    rem なにか処理を書く
    exit 0
)
Program.cs
System.Environment.Exit([戻り値]);

※[戻り値]の箇所は書き換えてください

2017/11/15 修正いたしました。

2
4
2

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
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?