Windows 10 – Which Command Executes with Multiple ‘Where’ Results?

anacondacmd.exewindows 10

I want to know the full path of a script/executable which is executed when I enter a command in (Anaconda) prompt.

When I type

where conda

I get three results


I thought I could narrow it down with

where "$path:conda"

But I got the same result.

Which of these three is actually executed when e.g. I run conda list?

Best Answer

The path variable stores paths defined by systems, programs and/or the user

This variable can be edited and paths can be added by the programs during the installation process, or also added by the user manually, but by itself it aims to facilitate that the software components are used / found.

When a command is executed, the system will try to execute it using the current folder, when it does not match, then it will go through each of the defined paths and obeying the order of occurrences delimiter by delimiter ; and will immediately run on the first match found, and only that one.

To find a file by searching in the current folder and all path defined in the path variable:

where file.ext 

To find a file by searching all paths defined in the path variable but not in the current folder:

where $path:file.ext

To find a file by searching only in the current folder without searching the path variable:

where .:"file.ext"

To find a file by searching the current folder and all its subfolders:

where /r . "file.ext"

To search for a file in a folder just specify:

where ""C:\Folder_001":"File.ext"

To search for a file in only two folders (or more)

where ""folder-1";"folder-2";"folder-3";"folder-n":file.ext"

where ""C:\Folder_001";"C:\Folder_002":file.ext"
where ""C:\Folder_001";"C:\Folder_001";"C:\Folder_002";"C:\Folder_003":file.ext"

To find a file by searching the current drive and all of its subfolders:

where /r \ file.ext

Obs.: 1 If you want all extensions, remove .ext

where /r . "file"

Obs.: 2 If the file has no spaces in the name and/or special characters, you can use it without double quotes:

where /r . file

Obs.: 3 Do not use \ at the end of the folder name, where you don't like this character at the end:

rem :: Dont' Use c:\folder + '\' ==  c:\folder\ 

where /r c:\folder_001\ file.ext

rem :: Use without \
where /r c:\folder_001 file.ext

Obs.: 4 Where can be used to find files length defined in the file name, where each ? == 1 character:

>where c:\windows:??.exe

>where c:\windows:???.exe

>where c:\windows:?????.exe

>where c:\windows:????????.exe

Related Question