What syntax will check if a variable name containing spaces is defined?

前端 未结 4 785
你的背包
你的背包 2021-01-05 11:45

Windows user defined environment variable names can contain any character except =.

Special characters can be included by escaping them. A simpler metho

4条回答
  •  心在旅途
    2021-01-05 12:00

    I do it by defining a flag as TRUE if needed...

    rem /* sample code */
    set VAR_SET=
    if  set VAR_SET=TRUE&set VAR=this data has spaces
    
    rem /* test for VAR_SET using 'if defined' */
    if defined VAR_SET (
      rem /* do something with the other data in the variable %VAR% */
    )
    
    rem /* clear the flag */
    set VAR_SET=
    

提交回复
热议问题