-
where
is a direct equivalent in cmd: where gccC:\Users\Administrator> where gcc D:\msys64\mingw64\bin\gcc.exe
Note that in PowerShell
where
itself is an alias forWhere-Object
, thus you need to usewhere.exe
in PowerShell. -
In >
cmd
you can also use : for %x in (gcc.exe) do @echo %~$PATH:xC:\Users\Administrator> for %x in (gcc.exe) do @echo %~$PATH:x D:\msys64\mingw64\bin\gcc.exe
-
In > PowerShell you have
Get-Command
and its aliasgcm
which does the same if you pass an argument (but also works for aliases, cmdlets and functions in PowerShell):PS C:\Users\Administrator> Get-Command gcc CommandType Name Version Source ----------- ---- ------- ------ Application gcc.exe 0.0.0.0 D:\msys64\mingw64\bin\gcc.exe
The first returned command is the one that would be executed.
Windows中查找命令的路径 (类似Linux中的which命令)
于 2024-09-05 14:58:36 首次发布