Chunky Chunk
Chunky Chunk

Reputation: 17217

Path for Command Line Prompt Across Windows OS

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.

Upvotes: 3

Views: 161

Answers (2)

dogbane
dogbane

Reputation: 274522

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

Upvotes: 1

Pekka
Pekka

Reputation: 449385

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.

Upvotes: 5

Related Questions