Mots clés : windowscommand-linepath-variableswindows
92
Set-Alias which where.exe
gcm notepad*
86
c:\> for %i in (cmd.exe) do @echo. %~$PATH:i C:\WINDOWS\system32\cmd.exe c:\> for %i in (python.exe) do @echo. %~$PATH:i C:\Python25\python.exe
@echo off setlocal enableextensions enabledelayedexpansion :: Needs an argument. if "x%1"=="x" ( echo Usage: which ^<progName^> goto :end ) :: First try the unadorned filenmame. set fullspec= call :find_it %1 :: Then try all adorned filenames in order. set mypathext=!pathext! :loop1 :: Stop if found or out of extensions. if "x!mypathext!"=="x" goto :loop1end :: Get the next extension and try it. for /f "delims=;" %%j in ("!mypathext!") do set myext=%%j call :find_it %1!myext! :: Remove the extension (not overly efficient but it works). :loop2 if not "x!myext!"=="x" ( set myext=!myext:~1! set mypathext=!mypathext:~1! goto :loop2 ) if not "x!mypathext!"=="x" set mypathext=!mypathext:~1! goto :loop1 :loop1end :end endlocal goto :eof :: Function to find and print a file in the path. :find_it for %%i in (%1) do set fullspec=%%~$PATH:i if not "x!fullspec!"=="x" @echo. !fullspec! goto :eof
71
$ Get-Command eventvwr CommandType Name Definition ----------- ---- ---------- Application eventvwr.exe c:\windows\system32\eventvwr.exe Application eventvwr.msc c:\windows\system32\eventvwr.msc
$ sal which gcm # short form of `Set-Alias which Get-Command` $ which foo ...
$ gcm *disk* CommandType Name Version Source ----------- ---- ------- ------ Alias Disable-PhysicalDiskIndication 2.0.0.0 Storage Alias Enable-PhysicalDiskIndication 2.0.0.0 Storage Function Add-PhysicalDisk 2.0.0.0 Storage Function Add-VirtualDiskToMaskingSet 2.0.0.0 Storage Function Clear-Disk 2.0.0.0 Storage Cmdlet Get-PmemDisk 1.0.0.0 PersistentMemory Cmdlet New-PmemDisk 1.0.0.0 PersistentMemory Cmdlet Remove-PmemDisk 1.0.0.0 PersistentMemory Application diskmgmt.msc 0.0.0.0 C:\WINDOWS\system32\diskmgmt.msc Application diskpart.exe 10.0.17... C:\WINDOWS\system32\diskpart.exe Application diskperf.exe 10.0.17... C:\WINDOWS\system32\diskperf.exe Application diskraid.exe 10.0.17... C:\WINDOWS\system32\diskraid.exe ...
$ $Env:PATHEXT="$Env:PATHEXT;.dll;.ps1;.psm1;.py" # temporary assignment, only for this shell's process $ gcm user32,kernel32,*WASM*,*http*py CommandType Name Version Source ----------- ---- ------- ------ ExternalScript Invoke-WASMProfiler.ps1 C:\WINDOWS\System32\WindowsPowerShell\v1.0\Invoke-WASMProfiler.ps1 Application http-server.py 0.0.0.0 C:\Users\ME\AppData\Local\Microsoft\WindowsApps\http-server.py Application kernel32.dll 10.0.17... C:\WINDOWS\system32\kernel32.dll Application user32.dll 10.0.17... C:\WINDOWS\system32\user32.dll
66
set-alias which where.exe
57
($Env:Path).Split(";") | Get-ChildItem -filter programName*