_EXPANSION returns the current expansion mode (i.e., SETDOS /X). It returns the string 0 if everything is enabled, or a string of up to 9 characters of the disabled modes.

 

For example, if you disable nested variable expansion and redirection:

 

setdos /x-46

 

then %_expansion will return 46.

 

Note that %_expansion will return %_expansion if you turn off variable expansion (setdos /x-3)!