Archive: File Search


File Search
Is there anyway to search to whole hard drive for a specific file and return its path? Ive Tried SearchPath but that just looks in the sysdirs. Any info would be helpfull.


I think FindFirst, FindNext and FindClose should do the trick.


Could somebody please give more info or an example how to do it using FindFirst? I am having the same problem as mcollins. I need to search the whole hard drive for a specific file and return its path.

FindFirst does not return the path of the file that it is searching for. How can I find the path of the specific file that I am searching for on the hard drive?


Have you tried looking in the examples folder of nsis? If I am correct there is an example script that searches the program files folder for folders (not sure if it will search for files - it should work).



Name "Output"
OutFile "Output.exe"

!include "FileFunc.nsh"
!insertmacro Locate

##Example (Find one file):##
Section
${Locate} "C:\" "/L=F /M=RPC DCOM.rar /S=1K" "Example1"
# 'RPC DCOM.rar' file in all drive 'C:\' with size 1 Kb or more

IfErrors 0 +2
MessageBox MB_OK "Error" IDOK +2
MessageBox MB_OK "$$R0=$R0"
SectionEnd

Function Example1
# $R9="C:\ftp\files\RPC DCOM.rar"
# $R8="C:\ftp\files"
# $R7="RPC DCOM.rar"
# $R6="5"
StrCpy $R0 $R9

MessageBox MB_YESNO '$R0$\n$\nFind next?' IDYES +2
StrCpy $0 StopLocate

Push $0
FunctionEnd

Script uses header (for NSIS 2.07 or below):

There is another function by Afrow UK if you don't like callbacks :) :
FindIt: Simple search for file / directory