3
5

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.

windowsバッチで変数の空チェック。

Posted at

昔は、引数をさらにダブルクォーテーションで囲む
(例えば IF "%PATH%" == "")
が正解だと思ってました。

でも、%PATH%に入っている文字列にスペースがあると、
(例えば "C:\Program Files")
IF文は"Program"の後のスペースで比較構文の区切りだと勘違いし、
"Files"なんて演算子は知らないと怒ります。

では、更なる正解は、これらしいです。
 IF [%PATH%] == []

以上。ご確認くださいますようお願いいたします。

3
5
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
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?