Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent of 'which' on the Windows command line? [closed]

As I sometimes have path problems, where one of my own cmd scripts is hidden (shadowed) by another program (earlier on the path), I would like to be able to find the full path to a program on the Windows command line, given just its name.

Is there an equivalent to the UNIX command 'which'?

On UNIX, which command prints the full path of the given command to easily find and repair these shadowing problems.

like image 395
namin Avatar asked Nov 20 '08 04:11

namin


People also ask

What is the equivalent of which command in Windows?

The where command is a Windows which equivalent in a command-line prompt (CMD). In a Windows PowerShell the alternative for the which command is the Get-Command utility.

What is the command for close?

When multiple open windows, files, or tabs are open, press Ctrl + F4 or Ctrl + W in Windows ( Command + W on a Mac) to close them one at a time without closing the program. In Microsoft Windows, programs that support Ctrl + W can also use the shortcut Ctrl + Shift + W to close all open tabs.

Which shortcut key is used to display and close the command-line?

Alt+F4 (or type “exit” at the prompt): Close the Command Prompt.


1 Answers

Windows Server 2003 and later (i.e. anything after Windows XP 32 bit) provide the where.exe program which does some of what which does, though it matches all types of files, not just executable commands. (It does not match built-in shell commands like cd.) It will even accept wildcards, so where nt* finds all files in your %PATH% and current directory whose names start with nt.

Try where /? for help.

Note that Windows PowerShell defines where as an alias for the Where-Object cmdlet, so if you want where.exe, you need to type the full name instead of omitting the .exe extension. Alternatively, you can set an alias for it:

Set-Alias which where.exe 

Update: Using Get-Command (alias: gcm) is recommended since it's native to PS and will get all command types: aliases, cmdlets, executables, and functions. Example:

gcm notepad* 
like image 138
Michael Ratanapintha Avatar answered Oct 17 '22 23:10

Michael Ratanapintha