I think you'll have to google something with "WMI VB.net"
|
|
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!![]()
I think you'll have to google something with "WMI VB.net"
"The world is coming to an end... SAVE YOUR BUFFERS !"
This does the trick BUT only when your administrator!!!!
Google impersonating vb.net wmi and you'll find a solution for non-admin users.
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 willCode:' 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
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 !"
Thanks for the response grmbl. I'll Google WMI Impersonation and try out the code!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks