[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 702
  • Last Modified:

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

    objRecordSet.movefirst
    Do Until objRecordSet.EOF
        MsgBox (objRecordSet.fields.Item("System.ItemPathDisplay"))
        objRecordSet.movenext
    Loop
    objConnection.Close
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??
0
PTBNA
Asked:
PTBNA
  • 3
  • 2
1 Solution
 
RobSampsonCommented:
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:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1014.mspx

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.

Regards,

Rob.
0
 
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.
0
 
RobSampsonCommented:
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:
http://www.developer.com/net/net/article.php/3678316

by using:
RemoteMachineName.SYSTEMINDEX

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

Regards,

Rob.
0
 
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.
0
 
RobSampsonCommented:
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.....

Regards,

Rob.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now