Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your immediate problem is that you're setting the variable to the value &lt; "Two"> which you can see here:</p> <pre><code>@echo off SETLOCAL ENABLEDELAYEDEXPANSION ::Observe variable is not defined SET test ::Define initial value SET test = "Two" ::Observe initial value is set SET test echo %test% echo..%test %. ::Verify if the contents of the variable matches our condition If "!test!" == "Two" GOTO TWO ::First Place holder :ONE ::Echo first response ECHO "One" ::Second Place holder :TWO ::Echo second response ECHO "Two" ::Await user input PAUSE ENDLOCAL </code></pre> <p>which produces:</p> <pre><code>Environment variable test not defined test = "Two" . "Two". "One" "Two" Press any key to continue . . . </code></pre> <p>The reason your "set test" is outputting the variable is the same reason why "set t" would - if there's no variable of the specific name, it outputs all variables starting with that name.</p> <p>The set command is also a finicky little beast and does not like spaces surrounding the '=' characters; it incorporates them (and the quotes by the way) into the environment variable name and the value assigned to it. Instead, use:</p> <pre><code>set test=Two </code></pre> <p>Also, where you're using delayed expansion, it doesn't matter since %test% and !test! would expand the same. It's useful in statements like:</p> <pre><code>if "!test!" == "Two" ( set test=TwoAndABit echo !test! ) </code></pre> <p>The inner echo will output TwoAndABit whereas %test%, which is expanded when the whole if-statement is encountered, would cause it to output Two.</p> <p>Still, I always use delayed expansion everywhere just for consistency.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload