I need to use a cmd.exe command line (cmd.exe is being called from the gyp build tool) to determine whether an environment variable is defined or not. How can I do this? I
If the extensions are really disabled (I can't believe this),
then you can try different ways.
IF %UNDEFINED% == %^UNDEFINED% (echo yes)
This works as if undefined doesn't exists then it isn't replaced, also ^undefined but the caret will be removed in the next parser phase, so %undefined% is compared against %undefined%.
The disadvantage are the missing quotes, as they also make the expression stable against special characters.
A better way is to use IF defined, but when extensions are disabled you need to enable them first.
cmd /E:on /c "if not defined undefined echo It's undefined"
The best way is to simply use a batch file, that should also work with gyp build system.