Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9227011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:57:56+00:00 2026-06-18T04:57:56+00:00

Does somebody have some example C# code about how objects from the Win32_ComputerSystem WMI

  • 0

Does somebody have some example C# code about how objects from the Win32_ComputerSystem WMI class can be retrieved from a remote system using hostname, username and password?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:57:57+00:00Added an answer on June 18, 2026 at 4:57 am

    Connecting:

    try
            {
                rcOptions = new ConnectionOptions();
                rcOptions.Authentication = AuthenticationLevel.Packet;
                rcOptions.Impersonation = ImpersonationLevel.Impersonate;
                rcOptions.EnablePrivileges = true;
                rcOptions.Username = servername + @"\" + username;
                rcOptions.Password = password;
    
                mScope = new ManagementScope(String.Format(@"\\{0}\root\cimv2", servername), rcOptions);
                mScope.Connect();
                if (mScope.IsConnected == true) { MessageBox.Show("Connection Succeeded", "Alert"); } else { MessageBox.Show("Connection Failed", "Alert"); }
                if (mScope.IsConnected == true) { lblConnectionStateWarning.Text = "Connected"; } else { lblConnectionStateWarning.Text = "Disconnected"; } //I have a label that displays connectionstate, you can leave that out
    
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
    

    Getting query with method, loading into dictonary & returning into listview

    private void FindWMI(string servername, string classSelection, ConnectionOptions rcOptions, ListView listView)
            {
                try
                {
                    var dct = new Dictionary<string, string>();
                    List<ListViewItem> itemsList = new List<ListViewItem>();
                    oQuery = new ObjectQuery("select * from " + classSelection);
                    moSearcher = new ManagementObjectSearcher(mScope, oQuery);
                    moCollection = moSearcher.Get();
    
                Invoke(new MethodInvoker(() =>
                {
                    listView.Items.Clear();
                }));
    
                foreach (ManagementObject mObject in moCollection)
                {
                    if (mObject != null)
                    {
                        foreach (PropertyData propData in mObject.Properties)
                        {
                            if (propData.Value != null && propData.Value.ToString() != "" && propData.Name != null && propData.Name != "")
                                dct[propData.Name] = propData.Value.ToString();
    //Don't forget this, when the result is an array, you want all the strings in that array..
    if (propData.Value is Array) { dct[propData.Name] = ""; foreach (string stringArray in (string[])propData.Value) { dct[propData.Name] += stringArray + "\n"; } }
                        }
                    }
                }
    
                foreach (KeyValuePair<string, string> listItem in dct)
                {
                    ListViewItem lstItem = new ListViewItem(listItem.Key);
                    lstItem.SubItems.Add(listItem.Value);
                    itemsList.Add(lstItem);
                }
    
                Invoke(new MethodInvoker(() =>
                {
                    listView.Items.AddRange(itemsList.ToArray());
                }));
            }
            catch (Exception) { }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody have any experience with TFS no longer letting somebody queue a new
Does somebody know a module, which has a function that returns ( for example
I'm using Ruby on rails. Does somebody know how can I insert a javascript
Can somebody explain to me what this does in javascript? (function (x,y){}(x,y)); or this
Can somebody tell me what does this mean? I'm going trough Java book and
Possible Duplicates: Does Java have a limit on the class name length? Max name
Does anyone can help me with caching a json string in Trigger.io? I have
Lets say in a file I have some code in two files part of
I am trying to integrate some pre-existing code that relies on the com.sun.crypto.provider.SunJCE class
I'm hoping somebody might be able to shed some light on this. We have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.