3

In command prompt, if net file is executed, it shows the resources that are open over any shared folders and it also shows the user name that is accessing the resource.

Example: net file example

The same information can be viewed from Computer Management (compmgmt.msc) -> System Tools -> Shared Folders -> Open Files.

Example: computer management open files example

The same information can be accessed using a VBScript:

Set objConnection = GetObject("WinNT://localhost/LanmanServer")
Set colResources = objConnection.Resources
For Each objResource in colResources
    Wscript.Echo "Path: " & objResource.Path
    Wscript.Echo "User: " & objResource.User
    Wscript.Echo
Next

How can this same information by accessed via C#? (without running the new file command from C# - this would truncate long path names in resources).

Is it possible to get to this information using WMI (which class? - I believe Win32_ServerConnection doesn't give the path of the resources that are open; same with Win32_ServerSession) or Netapi32.dll? If so, how can this be done?

Note: Need a way to get the full path of the file that is opened similar to the information in the screenshots from command prompt and computer management.

Any ideas?

slayernoah
  • 4,382
  • 11
  • 42
  • 73

0 Answers0