views:

33

answers:

2

this question might seem counter-useful.

the path for the windows command line prompt is different across several windows OSes. i'd like to know if there is a command i can enter in the command line prompt that will output the path of the command line prompt.

+5  A: 

The COMSPEC environment variable contains this information. It seems to be available consistently since the olden days of MS-DOS. (Wikipedia article)

echo %COMSPEC%

C:\Windows\System32\cmd.exe

Note that it can be altered freely using SET COMSPEC=, so it's not 1000% reliable.

Pekka
+1  A: 

I use a script called which.bat which prints out the full path to a specified executable (equivalent to Unix which or whereis):

@for %%e in (%PATHEXT%) do @for %%i in (%1%%e) do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i

So, to find out the path to the cmd program you would invoke the following:

> which.bat cmd
C:\WINDOWS\system32\cmd.exe
dogbane