Answers:
在这里命令你想要做什么,至少可以追溯到Windows 98的资源工具包,并在Server 2003中包含默认情况下,Windows Vista和更新:
C:\>where csc
C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe
如果不带任何参数执行(在Vista上),则会导致我最喜欢的消息之一:
C:\>where
ERROR: The operation completed successfully.
如果在PowerShell中执行,请确保包含“ .exe”以区别路径中的任何“ where”别名或脚本。(“ where”是Where-Object.ps1的典型别名)
C:\> where.exe where.exe
C:\Windows\System32\where.exe
where
刚刚返回使用帮助,现在在Windows 7中想看到它自己:对
where
在XP中不可用
骇客的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)
)
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;
}
例:
PS>找到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