Hello and thank you for reading my thread guys and girls. I am making a client/server project where the server can send a String variable to client but for now i'm starting with a simpler code. I was able to code a bit but now i'm having a problem with this UnauthorizedAccessException. It seems that I am not authenticated but i was able to put the admin username and its password. This is my problem.. Can anyone help me with this? Thank you in advance 
Here's my code...
Imports System
Imports System.Management.ManagementScope
Imports System.Management.Instrumentation
Imports System.Management
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim options As ConnectionOptions = New ConnectionOptions()
options.Username = "myUsername"
options.Password = "myPassword"
Dim theScope As New System.Management.ManagementScope("\\192.168.2.101\root\cimv2", options)
Dim theQuery As New System.Management.ObjectQuery("SELECT * FROM Win32_Account")
Dim theSearcher As New ManagementObjectSearcher(theScope, theQuery)
Dim theCollectionOfResults As ManagementObjectCollection = theSearcher.Get()
For Each currentResult As ManagementObject In theCollectionOfResults
MessageBox.Show(currentResult("Name").ToString())
Next
Catch ex As UnauthorizedAccessException
MessageBox.Show(ex.ToString)
End Try
End Sub
End Class
Ps. I'm using Win7
Here's my code...
Imports System
Imports System.Management.ManagementScope
Imports System.Management.Instrumentation
Imports System.Management
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim options As ConnectionOptions = New ConnectionOptions()
options.Username = "myUsername"
options.Password = "myPassword"
Dim theScope As New System.Management.ManagementScope("\\192.168.2.101\root\cimv2", options)
Dim theQuery As New System.Management.ObjectQuery("SELECT * FROM Win32_Account")
Dim theSearcher As New ManagementObjectSearcher(theScope, theQuery)
Dim theCollectionOfResults As ManagementObjectCollection = theSearcher.Get()
For Each currentResult As ManagementObject In theCollectionOfResults
MessageBox.Show(currentResult("Name").ToString())
Next
Catch ex As UnauthorizedAccessException
MessageBox.Show(ex.ToString)
End Try
End Sub
End Class
Ps. I'm using Win7