Zab*_*bba 121 windows command-line path
假设我在系统上的X.EXE
文件夹中安装了一个程序c:\abcd\happy\
.该文件夹位于系统路径上.现在假设系统上还有另一个程序,也称为X.EXE,但安装在文件夹中c:\windows\
.
是否有可能从命令行快速找出我是否输入X.EXE
了两个中的哪一个X.EXE
将被启动?(但无需在任务管理器中搜索或查看流程详细信息).
也许某种内置命令,或者那些可以做这样的事情的程序?:
detect_program_path X.EXE
Run Code Online (Sandbox Code Playgroud)
Chr*_*ich 220
使用该where
命令.列表中的第一个结果是将执行的结果.
C:\> where notepad C:\Windows\System32\notepad.exe C:\Windows\notepad.exe
根据这篇博客文章,where.exe
它包含在Windows Server 2003及更高版本中,所以这应该适用于Vista,Win 7等.
在Linux上,等效于which
命令,例如which ssh
.
Mic*_*urr 10
这是一个小cmd脚本,您可以将其复制粘贴到名为以下内容的文件中where.cmd
:
@echo off
rem - search for the given file in the directories specified by the path, and display the first match
rem
rem The main ideas for this script were taken from Raymond Chen's blog:
rem
rem http://blogs.msdn.com/b/oldnewthing/archive/2005/01/20/357225.asp
rem
rem
rem - it'll be nice to at some point extend this so it won't stop on the first match. That'll
rem help diagnose situations with a conflict of some sort.
rem
setlocal
rem - search the current directory as well as those in the path
set PATHLIST=.;%PATH%
set EXTLIST=%PATHEXT%
if not "%EXTLIST%" == "" goto :extlist_ok
set EXTLIST=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
:extlist_ok
rem - first look for the file as given (not adding extensions)
for %%i in (%1) do if NOT "%%~$PATHLIST:i"=="" echo %%~$PATHLIST:i
rem - now look for the file adding extensions from the EXTLIST
for %%e in (%EXTLIST%) do @for %%i in (%1%%e) do if NOT "%%~$PATHLIST:i"=="" echo %%~$PATHLIST:i
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
92783 次 |
最近记录: |