Home » Questions » Computers [ Ask a new question ]

Windows equivalent of whereis?

Windows equivalent of whereis?

Is there an equivalent of the Unix whereis command in Windows?

Asked by: Guest | Views: 397
Total answers/comments: 5
Guest [Entry]

"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"
Guest [Entry]

"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)
)"
Guest [Entry]

"I was searching for this today and since I'm on XP without the resource kit, I turned to powershell with the following command:

dir -path c:\ -filter ffmpeg.* -r"
Guest [Entry]

"function find ($string) {
Get-ChildItem -Path 'c:\' -Recurse -Filter $string;
}

function whereis ($string) {
$superpath = ""$env:Path;C:\Program Files;C:\Program Files (x86)"";
(echo $superpath).Split(';') | Get-ChildItem -Recurse -Filter $string;
}

Example:

PS >find Mozilla.admx

Directory: C:\Windows\PolicyDefinitions

Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 1/27/2016 12:22 PM 37146 Mozilla.admx

PS >whereis firefox.exe

Directory: C:\Program Files\Mozilla Firefox

Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 9/21/2017 5:30 PM 477136 firefox.exe"
Guest [Entry]

"Using the where command on windows 10, in cmd, I used the following command to recursively search c drive for copies of the c# compiler, csc.exe.

c:\> where /r c:\ csc.exe

Sample:
using where to find all copies of csc.exe"