{{Short description|Windows environment variable containing the directory path to the command shell}} '''{{mono|COMSPEC}}''' or '''{{mono|ComSpec}}''' is one of the environment variables used in DOS, OS/2 and Windows, which normally points to the command-line interpreter, which is by default {{mono|COMMAND.COM}} in DOS,<ref>{{cite book |title=PC-DOS 7.0 User Guide |date=January 1995 |publisher=IBM |pages=55, 283, 290 |edition=1st |ref=pcdos7guide |url=https://archive.org/details/pc-dos-7.0}}</ref> Windows&nbsp;95, 98, and ME or {{mono|CMD.EXE}} in OS/2 and Windows&nbsp;NT. The variable name is written in all-uppercase under DOS and OS/2. Under Windows, which also supports lowercase environment variable names, the variable name is defined as {{mono|ComSpec}} in the environment block, but as {{mono|COMSPEC}} inside the DOS emulator NTVDM.

When not present in the environment block, the command processor {{mono|CMD.EXE}} of Windows&nbsp;NT sets {{mono|COMSPEC}} to its own full path; it evaluates {{mono|COMSPEC}}, for example, to execute builtin commands in pipelines and to execute command lines with its builtin {{mono|FOR}} command.<ref>{{cite web |title=Idiosyncrasies – Odd, Surprising, Un(der)documented or Weird (Mis)behaviour of Microsoft<sup>®</sup> Windows<sup>®</sup> NT |url=https://skanthak.homepage.t-online.de/quirks.html}}</ref>

The variable's contents can be displayed by typing {{code|SET COMSPEC|dos}} or {{code|ECHO %COMSPEC%|dos}} at the command prompt.

The environment variable by default points to the full path of the command-line interpreter. It can also be made by a different company or be a different version.

Another use of this environment variable is on a computer with no hard disk, which needs to boot from a floppy disk, is to configure a RAM disk. The {{mono|COMMAND.COM}} file is copied to the RAM disk during boot, and the {{mono|COMSPEC}} environment variable is set to the new location on the RAM disk. This way the boot disk can be removed without the need to reinsert it after a big application has been stopped. The command-line interpreter will be reloaded from the RAM disk instead of the boot disk.

==References== {{Reflist}}

==External links== * [http://johnbokma.com/windows/command-prompt-shortcut.html Creating a customized Command Prompt shortcut]{{snd}} example of {{mono|COMSPEC}} usage

{{Disk operating systems}}

Category:Windows administration Category:DOS environment variables Category:Windows environment variables

{{windows-stub}}