OT: Rex, how does CMD handle its environment?

#1
Rex, you probably know more about how CMD works than most persons. I wrote this (below) in another thread. Please comment.

CMD must handle it's environment in a very peculiar way ... perhaps keeping a copy of it and **not** looking at the real environment when you query a variable with "SET varname". I'll start with this in in CMD:

Code:
C:\Users\vefatica> set q
q=666
 
C:\Users\vefatica> echo %q%
666
Now I'll use DynamicSetEnvVar (or my PSET) to set CMD's q to 999. Back in CMD I see:

Code:
C:\Users\vefatica> set q
q=666
 
C:\Users\vefatica> echo %q%
999
 
C:\Users\vefatica> set q
q=666
At this point, I can force CMD to update its copy (?) of the environment by (in CMD) setting some other variable!

Code:
C:\Users\vefatica> set x=0
 
C:\Users\vefatica> set q
q=999
 
C:\Users\vefatica> echo %q%
999