Windows equivalent of whereis?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 2
--
Chapters
00:00 Question
00:21 Accepted answer (Score 289)
01:12 Answer 2 (Score 16)
01:47 Answer 3 (Score 12)
02:14 Answer 4 (Score 7)
02:46 Thank you
--
Full question
https://superuser.com/questions/21067/wi...
Question links:
[whereis]: http://en.wikipedia.org/wiki/Whereis
Answer 1 links:
[Get-Command]: https://docs.microsoft.com/en-us/powersh...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows #commandline
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 2
--
Chapters
00:00 Question
00:21 Accepted answer (Score 289)
01:12 Answer 2 (Score 16)
01:47 Answer 3 (Score 12)
02:14 Answer 4 (Score 7)
02:46 Thank you
--
Full question
https://superuser.com/questions/21067/wi...
Question links:
[whereis]: http://en.wikipedia.org/wiki/Whereis
Answer 1 links:
[Get-Command]: https://docs.microsoft.com/en-us/powersh...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows #commandline
#avk47
ACCEPTED ANSWER
Score 299
The where command does what you want and goes back at least to the resource kit for Windows 98, and is included by default in Server 2003, Vista, and newer:
C:\>where csc
C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe
If executed with no arguments (on Vista), it results in one of my favorite messages:
C:\>where
ERROR: The operation completed successfully.
If executing in PowerShell, be sure to include '.exe' to distinguish from any 'where' aliases or scripts along the path. ('where' is a typical alias for Where-Object.ps1)
C:\> where.exe where.exe
C:\Windows\System32\where.exe
ANSWER 2
Score 14
Please, use where command:
> where app.exe
It is the best way to achieve your goal.
You can also use PowerShell command:
> $env:path.Split(';') | gci -Filter app.exe
and expanded version looks like this:
> $env:path.Split(';') | select -Unique | ? {$_ -and (test-path $_)} | gci -Filter app.exe
ANSWER 3
Score 7
hackerish which.cmd:
@echo off
@set PATH=.;%PATH%
@rem
@rem about: something similar like the unix-alike-which, but with
@rem within pure cmd
@rem
if "%1" == "" (
@echo Usage:
@echo.
@echo which 'cmd'
@echo.
@echo.if 'cmd' is not found, ERRORLEVEL is set to 1
@echo.
) else (
( @for %%f in (%1 %1.exe %1.cmd %1.bat %1.pif) do if not "%%~$PATH:f" == "" ( @echo %%~$PATH:f ) else @set ERRORLEVEL=1)
)
ANSWER 4
Score 3
Somewhere "out there" I found this batch file whereis.bat
:
@for %%e in (%PATHEXT%) do @for %%i in (%1%%e) do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i
Update: maybe I found it here.