If you’re used to working in a unix-like, you’ve probably made use of the which
command to find an executable… but what is the Windows command equivalent?

Windows command equivalent: Command Prompt version – where
where executable_file_name
will return the location of any executable file in the path that can be invoked by that file name. where more
will find more.com
and where cmd
will find cmd.exe
and print out the full path to each.
PowerShell version – Get-Command
Get-Command
(or its alias gcm
) will return an object representing the command that can be invoked by that name. If it is a distinct executable file, you can retrieve the string representation of the path by wrapping the invocation in parentheses and added .path
to extract the path, e.g., (gem cmd).path
. This won’t return anything for cmdlets but Get-Command
/gcm
will return an object representing how those commands are defined, whether they are cmdlets, aliases, or distinct executables.
