Variables are not behaving as expected

You are not the first, who fell into the famous “delayed expansion trap” (and you won’t be the last). You need delayed expansion if you want to use a variable, that you changed in the same block (a block is a series of commands within parentheses (and )). Delayed variables are referenced with !var! instead … Read more

How do SETLOCAL and ENABLEDELAYEDEXPANSION work?

I think you should understand what delayed expansion is. The existing answers don’t explain it (sufficiently) IMHO. Typing SET /? explains the thing reasonably well: Delayed environment variable expansion is useful for getting around the limitations of the current expansion which happens when a line of text is read, not when it is executed. The … Read more

Arrays, linked lists and other data structures in cmd.exe (batch) script

Ok. I’ll try to be as clear as possible to not be misunderstood… In Windows Batch files a variable name should begin with a letter and may include any valid character, where valid characters are: #$'()*+,-.?@[]_`{}~ besides letters and digits. This means that from the cmd.exe point of view, SET NORMAL_NAME=123 is exactly the same … Read more