Find out whether an environment variable contains a substring

后端 未结 4 1882
盖世英雄少女心
盖世英雄少女心 2020-12-16 14:21

I need to find out if a certain environment variable (let\'s say Foo) contains a substring (let\'s say BAR) in a windows batch file. Is there any way to do this using only

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 14:53

    @mythofechelon: The %var:str=% part removes str from var. So if var contains str on the left side of the equation, it will be removed on the right side - thus the equation will result in "false" if str was found in var or "true" if str was not present in var.

提交回复
热议问题