Sign in to follow this  
Followers 0
Bokkie

How to search for a file on all drives.

3 posts in this topic

Guys, first post, and congratulations to the authors for an amazing product!

For my first post I need to be able to search through all drives looking for a file that could literally be anywhere. The motiviation for doing this is that I need to run some MSDE database scripts but I need to check if there is an instance of MSDE and the database already created. I use InstallShield and it has an automatic search facility that will scan all local drives for a file and you can optionally set the maximum depth of directories it is to scan through.

I can't rely on a registry search and the database I'm looking for could be on any local HDD, and the directory name of the MSDE instance is not necessarily the same for all installations.

Is this possible in AutoIT?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Guys, first post, and congratulations to the authors for an amazing product!

For my first post I need to be able to search through all drives looking for a file that could literally be anywhere. The motiviation for doing this is that I need to run some MSDE database scripts but I need to check if there is an instance of MSDE and the database already created. I use InstallShield and it has an automatic search facility that will scan all local drives for a file and you can optionally set the maximum depth of directories it is to scan through.

I can't rely on a registry search and the database I'm looking for could be on any local HDD, and the directory name of the MSDE instance is not necessarily the same for all installations.

Is this possible in AutoIT?

Welcome to the forums! AutoIT is powerful and will certainly do what you have outlined.

Your problem needs nested loops.

You will need to do something like this (pseudocode):

Find all drives

-For each drive

--Find all folders/subdirectories

--For each directory

---Find file

----If found, do something

---Next file

--Next directory

-Next folder

Next drive

You either found it or you didn't

If you did,

-Go do your database stuff.

Else

-Problem handling

Finish

The help file is your friend. Look in FileFindFirstFile, DriveGetDrive and see the associated links and examples. The beta versions of AutoIT are fairly stable, and contain a lot of additional functionality - I suggest you explore those.

Searching these forums should also give you lots of examples where exactly this thing is done. You should have a look in the help file first however so you can understand what the various functions are.

Good luck!

Edited by Confuzzled

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks Confuzzled.

I was researching the function reference and thought I'd have to do it the way you suggested. I was kind of hoping there would be an off-the-shelf function that would do it. Time to start coding (crack fingers)... :o

I also noticed I can specify the type of drives I need to scan so I can restrict the search to just the local drives and not trawl across the network.

Edited by Peter Hamilton-Scott

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0