JSI Tip 8264. How can I open a Windows Explorer Search for Files and Folders from the command-line?
Jerold Schulman
July 15, 2004
1 Min Read
If you wanted to open a Search for Files and Folders from the command-line, you have a number of options:
To open a pre-configured search:
1. Open the Windows Explorer search manually.
2. Configure the search parameters, including any filtering you desire.
3. Perform the search. (you could Start the search and then Stop it.)
4. On the File menu, press Save Search.
5. Name the file with a .fnd extension, without any spaces in the name or folder path, like c:folder1mysearch.fnd.
6. In your script, add a line containing:
c:folder1mysearch.fnd ORstart c:folder1mysearch.fnd
To open an empty default search, using a .VBS file:
Add the following lines to your script:
@echo CreateObject("Shell.Application").FindFiles >"%temp%FindFile.vbs"cscript.exe //Nologo "%temp%FindFile.vbs"del /q /f "%temp%FindFile.vbs"
To open an empty default search, using standard commands:
Add the following line to your script:
type nul>mt.FND&start mt.FND&del /q /f /a mt.FND
If your %TEMP% environment variable defines a folder path without any spaces, you could use:
type nul>%TEMP%mt.FND&start %TEMP%mt.FND&del /q /f /a %TEMP%mt.FND
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like