Home

COMSPEC

ComSpec, officially referred to as the COMSPEC environment variable, designates the path to the command-line interpreter on Windows and DOS systems. It is used by the operating system and many applications to locate the program that should be used to run command-line processes. COMSPEC is inherited by child processes, enabling scripts and utilities to spawn a shell without hardcoding a specific executable.

In modern Windows installations based on the Windows NT lineage, COMSPEC typically points to the command processor

The variable is commonly accessed by users and software to determine how to invoke a command shell.

Although altering COMSPEC is possible through system environment settings, changing it can affect scripts, installers, and

See also: environment variables, CMD.EXE, COMMAND.COM.

CMD.EXE,
usually
located
in
the
System32
directory,
for
example
C:\Windows\System32\cmd.exe.
Historically,
in
DOS
and
Windows
9x
environments,
COMSPEC
pointed
to
COMMAND.COM,
the
native
command
interpreter
of
those
systems.
For
example,
a
script
or
program
may
reference
the
path
stored
in
COMSPEC
to
launch
a
new
command
interpreter
with
arguments
such
as
/c
to
execute
a
command
and
then
terminate.
It
is
also
viewable
at
a
command
prompt
with
a
query
like
echo
%COMSPEC%,
or
retrieved
through
system
APIs
that
expose
environment
variables.
utilities
that
rely
on
a
stable
reference
to
the
command
processor.
Therefore,
modifications
are
generally
discouraged
unless
there
is
a
specific
operational
need.