• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

Way to get open file info quickly

Hi Experts,

I have a problem with trying to get some information on open files out of our server.  The following
code works, but is deathly slow on all but the local server on the local sub-domain.  If I try to query a
server from another sub-domain across the WAN, it takes forever.  Is this because of a late-binding
issue?   I just wanted to speed up the process of obtaining this information and perhaps use
early-binding if possible.  Tools like the PSTOOLS by Winternals are extremely fast at returning
results no matter what server I query (and I want the same), but am stumped on how I could
approach this (or if it is even possible using ADSI?).  


    Dim fso As IADsFileServiceOperations
    Dim rs2 As IADsCollection
    Dim rs As IADsResource
    On Error GoTo Cleanup
    Set fso = GetObject("WinNT://" & Command$ & "/LanmanServer")
    Set rs2 = fso.Resources
    For Each rs In rs2
        List1.AddItem rs.Path
        If (Err.Number <> 0) Then
            MsgBox ("An error has occurred. " & Err.Number & vbCrLf & Err.Description)
        End If
        Set rso = Nothing
        Set rs = Nothing

  • 4
  • 3
1 Solution
The FSO is a lot slower then using API's to achieve getting or accessing any information with regards to access times take a look at these :


This scripting page ( which has a one to search files and attain file information ( not sure about getting it to do it remotely however )


Take a look here on comparison between API VS FSO :


You can also search around on the above site for any info with regards to getting remote file info.

Here is some www.pscode.com things to look at :


An Admin program in vb 6 using wmi and adsi ( Not sure how much help this will be to you ) :


I hope this helps you out some what.
sharizodAuthor Commented:
Hi Gecko_au2003,

Thanks for the response.  I want to try and get away from the vbscripting (either through VB itself or via scripts).
They only support late-binding for the methods they expose that deal with files.  Because of that, utilizing it
would be too slow for my application.  I do have some code that I picked up about a month ago that iterates through
the filesystem using the NetFileEnum API's.  It uses a couple of Copymemory tricks as well to get it to map the
necessary information in memory to make it all work.  I want to utilize this code because it works - with a catch.
It only works when executing it as an exe on the server that is running in the context of the domain admins or
administrators groups.  When I try to use the same code in an ActiveX DLL and try calling it in a web page, it
executes, but produces no results (unlike executing the EXE on the server).

Are there permissions attached to calling the NetFileEnum API??  If so, how can I get around it, and do you
know of any code that is ialready in .NET that utilizes that function to obtain open file information across

Best Regards & TIA.
sharizodAuthor Commented:
I just thought I'd mention I tried converting the vb6 code to .NET and there were so many issues with it, I just
couldn't get it to work.  A lot of the API calls involve parameters declared as type ANY, which .NET no longer
supports!  I understand I have to marshal them but I have tried to get the syntax down from a few code
examples, but came up empty-handed and more frustrated than ever.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

I am not really sure what else to suggest, as the only things I found relevant to what you are trying to do is in what I have posted, other then maybe take a look at www.sourceforge.net or www.sysinternals.com

They have some good stuff on them that you may find of use :)

Other then that I am sorry !
sharizodAuthor Commented:
Gecko, thanks for the help thus far, but I really haven't gotten much further than when I started
this question (sorry for the lag in response).   I've decided the users can live with a bit of
delay since the server or PC seems to cache the result and it seems to execute faster with
each run.

Thanks for trying,
what did you do in the end  and what happened exactly ?
sharizodAuthor Commented:
I was just perusing some of my old questions to find some answers with another problem I'm faced with and see
that I never answered you back here!  My apologies.  

Anyway.  What I did was to use rewrite it in .NET utilizing ADSI.  Then I used impersonation to get the
proper permissions to be able to successfully execute the ADSI queries.  I did have all sorts of trials
and tribulations upgrading the root Win2K PDC & IIS 5 to use the .NET framework  but came out on
top (although I still don't know HOW I did it)!!  

I still had permissions problems using traditional ASP and there was no way in heck that I was ever
going to get it to work properly other than using the traditional COM/NetFileEnum solution that had
already been in place (kept having IIS locking issues whenever a sync via FP2002 would be performed
and would have to rename the COM DLL or re-install IIS to be able to use it again).

Although it is true that ADSI is MUCH slower than the NetFileEnum version of my ASP DLL, the users
don't need THAT much of a real-time reporting solution.  All they use the web app/component for is
to see who is currently on the MRP system we use for the purpose of kicking them out (for those
processes that can be run with only one user in the system).  If and when I can ever get a workable
version utilizing the NetFileEnum API in .NET, I may switch over to that.

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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