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

后端 未结 26 2032
悲哀的现实
悲哀的现实 2020-11-22 00:40

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 pa

相关标签:
26条回答
  • 2020-11-22 00:44

    I have created tool similar to Ned Batchelder:

    Searching .dll and .exe files in PATH

    While my tool is primarly for searching of various dll versions it shows more info (date, size, version) but it do not use PATHEXT (I hope to update my tool soon).

    0 讨论(0)
  • 2020-11-22 00:45

    Not in stock Windows but it is provided by Services for Unix and there are several simple batch scripts floating around that accomplish the same thing such this this one.

    0 讨论(0)
  • 2020-11-22 00:46

    The GnuWin32 tools have which, along with a whole slew of other Unix tools.

    0 讨论(0)
  • 2020-11-22 00:48

    You can first install Git from Downloading Git, and then open Git Bash and type:

    which app-name
    
    0 讨论(0)
  • 2020-11-22 00:52

    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.

    0 讨论(0)
  • 2020-11-22 00:52

    I have used the which module from npm for quite a while, and it works very well: https://www.npmjs.com/package/which It is a great multi platform alternative.

    Now I switched to the which that comes with Git. Just add to your path the /usr/bin path from Git, which is usually at C:\Program Files\Git\usr\bin\which.exe. The which binary will be at C:\Program Files\Git\usr\bin\which.exe. It is faster and also works as expected.

    0 讨论(0)
提交回复
热议问题