Answers:
使用where
命令。列表中的第一个结果是将要执行的结果。
C:\>记事本 C:\ Windows \ System32 \ notepad.exe C:\ Windows \ notepad.exe
根据此博客文章,where.exe
Windows Server 2003和更高版本中包含该博客文章,因此,它仅适用于Vista,Win 7等。
在Linux上,等效which
命令是,例如which ssh
。
listdlls -d foo.dll
即可查看已加载模块的所有进程以及加载模块的完整路径。或者,您可以只在Windows文件中搜索文件名。
这是一个小cmd脚本,您可以将n-paste复制到一个名称如下的文件中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