Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Visual Studio .NET > VS.NET General Discussion

VS.NET General Discussion Anything related to Visual Studio and not covered in a topic forum. Please use a specific forum from the list below if able!

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-08-2009, 7:11 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jun 2009
Posts: 2
Reputation: 0
willBen is on a distinguished programming path ahead
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-08-2009, 9:52 AM
grmbl's Avatar
VB.NET Forum Enthusiast
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Jun 2009
Location: Belgium
Age: 27
Posts: 32
Reputation: 11
grmbl is on a distinguished programming path ahead
Default

I think you'll have to google something with "WMI VB.net"
__________________
"The world is coming to an end... SAVE YOUR BUFFERS !"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-08-2009, 10:14 AM
grmbl's Avatar
VB.NET Forum Enthusiast
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Jun 2009
Location: Belgium
Age: 27
Posts: 32
Reputation: 11
grmbl is on a distinguished programming path ahead
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 !"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-08-2009, 10:28 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jun 2009
Posts: 2
Reputation: 0
willBen is on a distinguished programming path ahead
Talking

Thanks for the response grmbl. I'll Google WMI Impersonation and try out the code!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
hidden shares


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 8:24 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.