Use of Windows undefined environment variable? Use of Windows undefined environment variable? windows windows

Use of Windows undefined environment variable?


Really good question! Confusing huh?

There are actually two distinct parsers used to parse batch scripts and command line commands.

Quote from this excellent answer:

BatchLineParser - The parser inside of batch files, for lines or blocks

CmdLineParser - Like the BatchLineParser, but directly at the command prompt, works different

The key difference is in the first phase of parsing, particularly the extension of %var%:

In BatchLineParser if var does not exists will be replaced with nothing, in CmdLineParser if the var isn't defined, the expression will be unchanged.

So why did someone design it this way? I have absolutely no idea.