_BGCOLOR — Returns the desktop background color.

Syntax:
%_BGCOLOR

The color will be returned as a six-digit hexadecimal number with a leading # sign.

rem  Save the current background color:
set backcolor=%_bgcolor


See also: the BGCOLOR command, which sets or displays the background color; and the _BGCOLORNAME variable, which reports it as a W3C color name if possible.