How do shortcuts to cmd.exe store settings for the program?

by tesselode   Last Updated July 12, 2019 06:01 AM

If you right click a shortcut to cmd.exe, you'll see not only the regular properties that you'd see for every shortcut, but also properties for the console emulator.

A screenshot of the cmd.exe right-click properties

My question is, how is this actually possible? I've never seen another Windows program work this way. Is cmd taking advantage of an infrequently used API, or does Windows have special handling for this program and this program alone?



Answers 1


No; Windows has special handling for all console applications. Unlike e.g. Linux programs, each Windows .exe has a bit in its header that indicates whether this is a "console" or "windowed" executable.

Windows Explorer – the program that displays these "Properties" dialogs – recognizes console apps from this header field and shows additional settings. (It even shows more settings for 16-bit apps which use NTVDM. Remember .pif files?)

Each newly created console window will pick up settings from under HKEY_CURRENT_USER\Console, which has subkeys (subfolders) based on the executable name or the initial window title. If there are no matching subkeys, it will also (through some unknown mechanism) pick up settings stored within the shortcut's .lnk file, as in the screenshot you provided.

See also:

grawity
grawity
July 12, 2019 05:52 AM

Related Questions


Updated July 29, 2019 08:01 AM

Updated May 25, 2017 03:01 AM

Updated December 10, 2015 12:00 PM

Updated December 28, 2017 07:01 AM

Updated March 30, 2018 12:01 PM