We help IT Professionals succeed at work.

How to retrieve mapped drives and printers of remote machine for whatever user is logged on.

solomonacquah
on
954 Views
Last Modified: 2008-02-01
I have written this vb form that allows you to enter a node name and retrieve mapped drives and printers of the machine it is ran on. The Problem is that I need to be able to retrieve this information from remote machines. But do not know how.  When I enter a remote machine name It retrieves nothing, but when ran on my machine is retreives everything.  Can I use impersonation somehow so that when I enter a remote machine, it will know who is logged onto that machine and then retrieve the mapped drives and printers from that logged on user?  thank You

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        'On Error Resume Next
        Dim objWMIService, strcomputer, colitems, objitem

       
        strcomputer = TextBox1.Text

        'get mapped printers
        objWMIService = GetObject("winmgmts:\\" & strcomputer & "\root\cimv2")

        colitems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer")


        For Each objitem In colitems
            If objitem.network = True Then
                RichTextBox1.Text = RichTextBox1.Text & objitem.deviceID & vbCrLf

            End If
        Next
       
        'get mapped drives
        objWMIService = GetObject("winmgmts:\\" & strcomputer & "\root\CIMV2")

        colitems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk where" _
         & " Description = 'Network Connection'")

        For Each objitem In colitems
            RichTextBox2.Text = RichTextBox2.Text & objitem.providername & vbCrLf

               Next
    End Sub
Comment
Watch Question

Author

Commented:
refund please
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you very much Graye
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.