4

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

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.

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...?

Kara
  • 6,115
  • 16
  • 50
  • 57
IQpierce
  • 501
  • 2
  • 8
  • 17

11 Answers11

5

Use Locate32

This isn't the exact answer to your question, but you could use Locate32 instead 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.

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

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

where the -r switch 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:\home is the path to search.

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

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.

Charles Roper
  • 20,125
  • 20
  • 71
  • 101
4

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

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"

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

Vitim.us
  • 20,746
  • 15
  • 92
  • 109
4

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.

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.

bruceatk
  • 5,118
  • 2
  • 26
  • 36
  • Fantastic. I had no idea you could save searches, and I'm amazed that XP doesn't even allow you to launch this from the command line. But this method allows me to do what I want (which, to clarify, was be able to quickly launch a dialog for searching my c:\dev\src directory with a hotkey any time). – IQpierce Sep 18 '08 at 21:38
  • You gotta love context sensitive menus which give you no clue as to what is possible, unless you already know the answer. :) – bruceatk Sep 18 '08 at 23:04
3

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.

Try this

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

And compile it with cscript /nologo ExplorerFind.vbs

Pascal Paradis
  • 4,275
  • 5
  • 37
  • 50
  • http://groups.google.com/group/microsoft.public.windowsxp.general/browse_thread/thread/774824ca6397321a/9d4efc5b66cdd287?lnk=st&q=explorer+search+command+line#9d4efc5b66cdd287 mentions something about $SEARCH$, but I don't know what context that is. I even resorted to CUIL to search the dollar signs – Brian Sep 18 '08 at 18:59
3

from 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
Brian
  • 5,826
  • 11
  • 60
  • 82
  • I haven't tried this; it looks like it might actually accomplish what I want... except that it's not clear whether I'd be able to tell it "search under directory X" as it launched... – IQpierce Sep 18 '08 at 21:41
0

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.

Tom
  • 1
0

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

Trevor
  • 525
  • 2
  • 6
  • 19
0

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

DustinB
  • 11,037
  • 5
  • 46
  • 54
0

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

jfs
  • 399,953
  • 195
  • 994
  • 1,670
0

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):

What are good grep tools for Windows?

Community
  • 1
  • 1
Ben Dunlap
  • 1,838
  • 1
  • 16
  • 17
-1

Why don't you try bashing F3? :)

Dan
  • 61,568
  • 9
  • 61
  • 78
  • I'm not sure why someone marked this down. This is the correct answer. – bruceatk Sep 18 '08 at 18:54
  • No it's not. The OP asked, "[...] I need to know a command-line statement to run in order to open the standard Windows 'Find Files/Folders' dialog". So "Bashing F3" is definitely not the correct answer. – Charles Roper Sep 18 '08 at 19:16
  • It's the most correct so far. His goal is to create a hotkey. F3 is a hotkey, so is Win + F. The second part of his question is tough to do. – bruceatk Sep 18 '08 at 19:46
  • Half an answer still isn't an answer, though. :) – Charles Roper Sep 19 '08 at 17:02