_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.