That's normal behavior when typing those commands at a command prompt. Been that way since NT 4.0, if not earlier.
At the Command Line, if a variable is undefined, Echo will echo exactly what you typed, it doesn't substitute a null value for the undefined variable. Same with If.
It only works if the statements are executed in a batch file.
If it's not working when executed from within a batch file, I haven't a clue, as it still works for me. Assuming you've rebooted, make sure you are opening the real cmd.exe by typing
c:\Windows\System32\cmd.exe into the run box.
Run
SFC /SCANNOW to check for corrupted system files.
This file works as expected for me, just tested on NT4.0, Win2K, XP-SP0, XP-SP2, XP-SP3, Win7:
Code:
set VALUE=
echo %VALUE%
if x%VALUE% == x echo Empty
Code:
E:\Scripts>EVTest.cmd
E:\Scripts>set VALUE=
E:\Scripts>echo
ECHO is on.
E:\Scripts>if x == x echo Empty
Empty
E:\Scripts>
Since value is undefined, the echo statement simply echos the current echo setting.
Also tested with Command Extensions disabled.
If your variable contains spaces you will get an error:
Code:
Set VALUE=TEST DATA
If x%VALUE%==x Echo Empty
Will tell you
DATA was unexpected at this time.
You should use this format instead:
Code:
Set VALUE=TEST DATA
If "%VALUE%"=="" Echo Empty