+ Reply to Thread
Results 1 to 4 of 4

Thread: Search for Administrative(Hidden) Shares

  1. #1
    willBen is offline VB.NET Forum Newbie willBen is on a distinguished programming path ahead
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2009
    Posts
    2
    Reputation
    0

    Default Search for Administrative(Hidden) Shares

    Hi All,

    I am really new to programming and I have decided to teach myself VB.NET. My first project to get things going is a Network search app. Basically, type in your search criteria and click on "go". The app will return all shared files with your criteria. The app works just fine, but i have noticed that there are certain shares here at the office that it doesn't pick up.

    EG: \\ServerName\Movies$.

    In a round about way I use Command Prompt to return the shares, but I am unable to return the hidden shares. Is there a command I am missing out on? Or am I doing this incorrectly? Google, my best friend, seems to only want to sell me software when I search on the subject.

    Any and all assistance will be appreciated.

    BTW. Have to say that VB is a very user friendly language and I really enjoy programming with it!

  2. #2
    grmbl's Avatar
    grmbl is offline VB.NET Forum Enthusiast grmbl is on a distinguished programming path ahead
    .NET Framework
    .NET 3.0 (VS 2005/2008)
    Join Date
    Jun 2009
    Location
    Belgium
    Age
    27
    Posts
    32
    Reputation
    18

    Default

    I think you'll have to google something with "WMI VB.net"
    "The world is coming to an end... SAVE YOUR BUFFERS !"

  3. #3
    grmbl's Avatar
    grmbl is offline VB.NET Forum Enthusiast grmbl is on a distinguished programming path ahead
    .NET Framework
    .NET 3.0 (VS 2005/2008)
    Join Date
    Jun 2009
    Location
    Belgium
    Age
    27
    Posts
    32
    Reputation
    18

    Default

    This does the trick BUT only when your administrator!!!!
    Google impersonating vb.net wmi and you'll find a solution for non-admin users.

    Code:
    ' also import these through project - add reference...
    Imports System.Management
    Imports System.IO
    
    Public Function GetShares(ByVal Machine As String) As DataSet
            On Error Resume Next
    
            Dim ds_shares As New DataSet
            Dim scope As New ManagementScope("\\" + Machine + "\root\cimv2")
            scope.Connect()
    
            Dim objectQuery As New ObjectQuery("select * from Win32_Share")
            Dim searcher As New ManagementObjectSearcher(scope, objectQuery)
            Dim os As ManagementObject
            Dim sXML As String
            Dim sep As String = vbCrLf
            sXML = "<ServerInfo>"
            Dim moColl As ManagementObjectCollection = searcher.Get()
    
            For Each os In moColl
                sXML = sXML & sep & "<Information Field='Share' Value='" & os("name") & " (" & os("path") & ")'/>"
            Next os
    
            sXML += "</ServerInfo>"
            Dim SR As New StringReader(sXML)
            ds_shares.ReadXml(SR)
    
            Return ds_shares
    End Function
    
    'usage
    Dim ds As DataSet = GetShares("servername")
    
    For Each r As DataRow In ds.Tables(0).Rows
       MsgBox(r.Item("Value"))
    Next
    If you put a breakpoint on the line where the dataset is declared and you debug, you can select the word "ds" and a tooltip will
    come up with everything about this dataset. There's also a magnifier, if you click on it you can SEE the dataset!

    Hope that helps you on your way!
    "The world is coming to an end... SAVE YOUR BUFFERS !"

  4. #4
    willBen is offline VB.NET Forum Newbie willBen is on a distinguished programming path ahead
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2009
    Posts
    2
    Reputation
    0

    Talking

    Thanks for the response grmbl. I'll Google WMI Impersonation and try out the code!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts