Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I find out to which filepath (or alias) a certain command input will point to, in the Windows command prompt? Specifically Windows XP, info on other versions also appreciated!

On Unix systems I simply use:

$ which commandname
/a/commandname

Or:

$ type -a commandname
commandname is aliased to `/b/commandname'
commandname is /a/commandname
commandname is /b/commandname

And I am simply looking for the equivalent in the Windows Shell (specifically Win XP).


I came to this general question, from a specific issue: I had installed robocopy.exe (version 026), but the command line "robocopy" always triggers version 010, and I would like to determine where this command points to, in order to correct this mistake.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Newer Windows distributions have the where command. Read here for more info. For Windows XP you can use

   c:\> for %i in (cmd.exe) do @echo.   %~$PATH:i
   C:\WINDOWS\system32\cmd.exe

as one of the answers describes on the page I already linked to.

share|improve this answer

I found this simple Windows batch file:

@echo off
rem --------------------------------------------------------
rem File: which.cmd
rem Description: Windows equivalent of Unix which command
rem Author: Pankaj Kumar
rem Copyright 2004 Pankaj Kumar. All Rights Reserved.
rem License: This software is available under GPL
rem ---------------------------------------------------------
setlocal
if "%1" == "" goto noArg

set fullpath=%~$PATH:1
if "%fullpath%" == "" goto notFound
echo Found in PATH: %fullpath%
goto end

:noArg
echo No Argument specified
goto end

:notFound
echo Argument "%1" not found in PATH

:end
endlocal

From help for:

%~$PATH:I   - searches the directories listed in the PATH  
               environment variable and expands %I to the  
               fully qualified name of the first one found.  
               If the environment variable name is not  
               defined or the file is not found by the  
               search, then this modifier expands to the  
               empty string`
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.