System.Management

  • Thread starter Thread starter Frank Ashley
  • Start date Start date
F

Frank Ashley

The code below returns all files on the local machine. I want to scan a
different machine and have tried to use the ManagmentPath class but I can't
see where I would fit it into the current code. Can anybody help?

Dim mySelect As New SelectQuery("select * from cim_datafile")
Dim myResults As New ManagementObjectSearcher(mySelect)
Dim myProperty As PropertyData

For Each wmiObject As ManagementObject In myResults.Get()
For Each myProperty In wmiObject.Properties
lblInfo.Text &= myProperty.Name & Space(10) &
Convert.ToString(myProperty.Value) & vbCrLf
Next
Next wmiObject



Thank you
Frank Ashley
 
Before you loop through:

myResults.Scope.Path.Path = "\\<computer name>\root\cimv2"
myResults.Scope.Options.UserName = <user id having full access to the
computer>
myResults.Scope.Options.Password = <password of the above user id>

HTH

The code below returns all files on the local machine. I want to scan a
different machine and have tried to use the ManagmentPath class but I can't
see where I would fit it into the current code. Can anybody help?

Dim mySelect As New SelectQuery("select * from cim_datafile")
Dim myResults As New ManagementObjectSearcher(mySelect)
Dim myProperty As PropertyData

For Each wmiObject As ManagementObject In myResults.Get()
For Each myProperty In wmiObject.Properties
lblInfo.Text &= myProperty.Name & Space(10) &
Convert.ToString(myProperty.Value) & vbCrLf
Next
Next wmiObject



Thank you
Frank Ashley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top