Scripting Desktop Search to search network Drives

This code works for the local Drive:
Private Sub GetScriptedFileSystem()
    Set objConnection = CreateObject("ADODB.Connection")
    Set objRecordSet = CreateObject("ADODB.Recordset")

    objConnection.Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"

   objRecordSet.Open "SELECT System.ItemPathDisplay FROM SYSTEMINDEX Where System.ItemFolderPathDisplay = 'C:\' AND System.ItemType <> 'folder'", objConnection

    Do Until objRecordSet.EOF
        MsgBox (objRecordSet.fields.Item("System.ItemPathDisplay"))
End Sub

But if I change the Drive letter to a Netwoked drive: "P:\" then no records are returned.  Any Idea how to work around this??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You would have to know the name of the server where that drive points to, and use a remote query against that server, which is illustrated here:

The main reason you can't read that, I believe, is because P drive is not a system drive of the machine you're executing it on.


PTBNAAuthor Commented:
Not sure about "System Drive", but the P is mapped to the server.

I also tried using this format to reach drive:  //fileserver/myshare/folder/  which also wouldn't work.  

I'll take a look at the scriptcenter and see if I can get it to work.  Using some standard drive/folder/file read functions it takes about 1.5 minutes to run.   I'm guessing using the recordset functions would be a lot faster.
Sorry, I may have confused you.  What I was getting at, is that because P drive physically exists on a remote PC, then you cannot run a local query to browse that drive.  It looks as if this method *can* be extended to remote PCs however:

by using:

So, as long as you know whether P drive is mapped to a share on the C or D of the remote server, you should be able to use:
strServer = "REMOTEPC"
objRecordSet.Open "SELECT System.ItemPathDisplay FROM " & strServer & ".SYSTEMINDEX Where System.ItemFolderPathDisplay = 'C:\' AND System.ItemType <> 'folder'", objConnection



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PTBNAAuthor Commented:
I'll give that a try.  Thanks for the help.  I have a work around working, but this looks like it would be a faster way to retrieve the file names.

At this time we are running Vista, and it looks more like a security issue than a programming one.  I'll try to see if it will work, but not holding out much hope without a lot of re-programming in excel to bypass the "Security" features.
No worries, good luck and thanks for the grade.  Unfortunately, I don't use Vista, so I am unable to provide a more clear cut solution.....


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.