Parenthesis in variables inside IF blocks

后端 未结 5 1024
天命终不由人
天命终不由人 2021-02-07 12:12

In one of my scripts, I need to use variables that contain parenthesis inside IF statements, but either the string is missing a closing parenthesis or the script ex

5条回答
  •  清歌不尽
    2021-02-07 13:06

    Forgive me if I'm reading this wrong, but isn't the "NOT" causing control to enter the bracketed if and run the broken output?

    what about:

    @echo off
    
    echo Perfect output: %programFiles(x86)%
    IF NOT "%programFiles(x86^)%" ==  "" (
        REM Variable is defined
        echo Broken output:  %programFiles(x86)%
    ) 
    
    pause >nul
    

    ?

提交回复
热议问题