如何从 Windows XP 中的命令行打开“查找文件”对话框以搜索特定文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/95432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:14:22  来源:igfitidea点击:

How do I open "Find Files" dialog from command-line in Windows XP to search a specific folder?

windowswindows-xp

提问by IQpierce

I'd like to create a hotkey to search for files under a specific folderin Windows XP; I'm using AutoHotkey to create this shortcut.

我想创建一个热键来搜索Windows XP 中特定文件夹下的文件;我正在使用 AutoHotkey 创建此快捷方式。

Problem is that I need to know a command-line statement to run in order to open the standard Windows "Find Files/Folders" dialog. I've googled for a while and haven't found any page indicating how to do this.

问题是我需要知道要运行的命令行语句才能打开标准的 Windows“查找文件/文件夹”对话框。我已经用谷歌搜索了一段时间,但没有找到任何说明如何执行此操作的页面。

I'm assuming that if I know the command-line statement for bringing up this prompt, it will allow me to pass in a parameter for what folder I want to be searching under. I know you can do this by right-clicking on a folder in XP, so I assume there's some way I could do it on the command line...?

我假设如果我知道用于显示此提示的命令行语句,它将允许我传入一个参数,用于我想在哪个文件夹下进行搜索。我知道您可以通过右键单击 XP 中的文件夹来执行此操作,所以我假设有某种方法可以在命令行上执行此操作...?

采纳答案by Brian

from http://www.pcreview.co.uk/forums/thread-1468270.php

来自http://www.pcreview.co.uk/forums/thread-1468270.php

@echo off
echo CreateObject("Shell.Application").FindFiles >%temp%\myff.vbs
cscript.exe //Nologo %temp%\myff.vbs
del %temp%\myff.vbs

回答by Charles Roper

Use Locate32

使用Locate32

This isn't the exact answer to your question, but you could use Locate32instead of the Windows search facility. It has a whole suite of command-line options plus has the huge benefit of being an indexed search, which means the results will display instantaneously. It's a tool I can't be without on Windows.

这不是您问题的确切答案,但您可以使用Locate32而不是 Windows 搜索工具。它有一整套命令行选项,并且具有作为索引搜索的巨大好处,这意味着结果将立即显示。这是我在 Windows 上不可缺少的工具。

This is the command you would issue to search for all index.phpfiles in D:\home:

这是您在搜索 中的所有index.php文件时会发出的命令D:\home

locate32.exe -r -p D:\home index.php

where the -rswitch makes Locate32 search immediately without user intervention (without it, the interface would launch and the fields would be populated, but you'd have to hit Enter to proceed with the search) and -p D:\homeis the path to search.

-r开关使Locate32搜索立即无需用户干预(没有它,界面将启动和领域将被填充,但你必须按下回车键与搜索进行),并-p D:\home是要搜索的路径。

Using AutoHotKey, it's simple to assign the above command to a keyboard shortcut.

使用 AutoHotKey,将上述命令分配给键盘快捷键很简单。

There is also a fully command-line based version of Locate32 in the same package called locate.exe. This uses the same indexes as Locate32, but because it is completely CLI-based, can be used by scripting languages and other tools to take advantage of the blistering search performance it offers.

在同一个包中还有一个完全基于命令行的 Locate32 版本,名为locate.exe. 它使用与 Locate32 相同的索引,但因为它完全基于 CLI,脚本语言和其他工具可以使用它来利用它提供的快速搜索性能。

回答by bruceatk

F3 or Win+F is a hotkey that will launch Find Files. If you then do a search using the criteria you want, you can save the search using the File menu. This creates a .FND file. The FND file can be launched from the command line or from a hot key created with autohotkey.

F3 或 Win+F 是启动查找文件的热键。如果您随后使用所需条件进行搜索,则可以使用“文件”菜单保存搜索。这将创建一个 .FND 文件。FND 文件可以从命令行或使用 autohotkey 创建的热键启动。

It is possible to edit the .FND file (binary) and change what it is searching for, but I would avoid doing that unless it's the only way you can accomplish what you want. I tried it and it worked fine.

可以编辑 .FND 文件(二进制)并更改它正在搜索的内容,但我会避免这样做,除非这是您可以完成所需的唯一方法。我试过了,效果很好。

回答by Vitim.us

just execute this line! (WinKey+R, CmdPrompt, Shortcut, ShellExecute, WinExec, etc)

只需执行这一行!(WinKey+R、CmdPrompt、快捷方式、ShellExecute、WinExec 等)

search-ms:query=New%20Folder&

Find all shortcuts in your desktop

查找桌面上的所有快捷方式

search-ms:query=*.lnk&crumb=folder:%userprofile%\Desktop&

Find the text "exe" in the folder "C:\Program Files"

在文件夹“C:\Program Files”中找到文本“exe”

search-ms:query=exe&crumb=location:C:\Program Files&

Other exemples

其他例子

search-ms:query=microsoft&
search-ms:query=vacation&subquery=mydepartment.search-ms&
search-ms:query=seattle&crumb=kind:pics& 
search-ms:query=seattle&crumb=folder:C:\MyFolder&

reference here http://msdn.microsoft.com/en-us/library/ff684385.aspx

在这里参考http://msdn.microsoft.com/en-us/library/ff684385.aspx

回答by Pascal Paradis

There is no way from command line to get Explorer to show the Search Files pane. But you can get over it with some VBScript.

命令行无法让资源管理器显示“搜索文件”窗格。但是您可以使用一些 VBScript 来克服它。

Try this

尝试这个

'ExplorerFind.vbs
Dim objShell
Set objShell = WScript.CreateObject("Shell.Application")
objShell.FindFiles

And compile it with cscript /nologo ExplorerFind.vbs

并用 cscript /nologo ExplorerFind.vbs 编译

回答by Ben Dunlap

It's a little unclear whether the end-result you want is the open "find" dialog, or if you're just looking for a command-line way to search an arbitrary directory. If the latter there's FINDSTR (assuming you want to search the content of files and not their names):

有点不清楚您想要的最终结果是打开的“查找”对话框,还是只是在寻找一种命令行方式来搜索任意目录。如果后者有 FINDSTR (假设您要搜索文件的内容而不是它们的名称):

What are good grep tools for Windows?

什么是适用于 Windows 的好 grep 工具?

回答by DustinB

Try "Launchy". For windows and linux. Awesome util.

尝试“启动”。对于 windows 和 linux。很棒的实用程序。

回答by jfs

If you need just a hotkey then use Win+f.

如果您只需要一个热键,请使用Win+f.

回答by Tom

Addition to Ben Dunlap's answer: You could also use FINDSTR on the output of the DIR command (for instance in a FOR loop) This would search for filenames, not in files.

除了 Ben Dunlap 的回答:您还可以在 DIR 命令的输出上使用 FINDSTR(例如在 FOR 循环中)这将搜索文件名,而不是在文件中。

回答by Trevor

Based on the answer by Vitim.us from cmd all you need is explorer.exe "search-ms:query=*.exe&crumb=location:C:\Program Files&"Change the location and query as needed

根据来自 cmd 的 Vitim.us 的回答,您只需要根据需要 explorer.exe "search-ms:query=*.exe&crumb=location:C:\Program Files&"更改位置和查询