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

  • Home
  • SEARCH
  • 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 8997039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:50:05+00:00 2026-06-15T23:50:05+00:00

i have a simple Problem. I cant read a specific Instance of an WMI

  • 0

i have a simple Problem. I cant read a specific Instance of an WMI class.

ManagementScope scope = new ManagementScope(@"\\.\root\OpenHardwareMonitor", null);
scope.Connect();
ManagementPath printersPath = new ManagementPath("Sensor");            
ObjectGetOptions options = new ObjectGetOptions(null, TimeSpan.MaxValue, true);

ManagementClass printersManager = new ManagementClass(scope, printersPath, options);
foreach (ManagementObject printer in printersManager.GetInstances())
{
    Console.WriteLine(printer["Name"]);
}

ManagementPath path = new ManagementPath(scope.Path + ":Sensor.Name='CPU'");

ManagementObject disk = new ManagementObject();
disk.Path = path;
disk.Get();

Here i get an exception, but the upper list works and ‘CPU’ is shown.

The Exeption points to the ‘;’ of Get(). Details: (using German VS12)

System.Management.ManagementException wurde nicht behandelt.
  HResult=-2146233087
  Message=Ungültiger Objektpfad <--- invalid objektpath
  Source=System.Management
  StackTrace:
       bei System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
       bei System.Management.ManagementObject.Get()
       bei Hello_openHWM.Program.getCPUTemp() in c:\Users\XXX\Documents\Visual Studio 2012\Projects\Hello openHWM\Hello openHWM\Program.cs:Zeile 46.
       bei Hello_openHWM.Program.Main(String[] args) in c:\Users\XXX\Documents\Visual Studio 2012\Projects\Hello openHWM\Hello openHWM\Program.cs:Zeile 18.
       bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bei System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

What am i doing wrong? I am new to C#

  • 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-15T23:50:06+00:00Added an answer on June 15, 2026 at 11:50 pm

    It seems which you are passing the wrong WMI object path to the WMI, as workaround you can use a WQL sentence to retrieve the proper data.

    using System;
    using System.Collections.Generic;
    using System.Management;
    using System.Text;
    
    namespace GetWMI_Info
    {
        class Program
        {
    
            static void Main(string[] args)
            {
                try
                {
                    ManagementScope Scope;                
                    Scope = new ManagementScope(String.Format("\\\\{0}\\root\\OpenHardwareMonitor", "."), null);
    
                    Scope.Connect();
                    ObjectQuery Query = new ObjectQuery("SELECT * FROM Sensor Where Name LIKE 'CPU%'");
                    ManagementObjectSearcher Searcher = new ManagementObjectSearcher(Scope, Query);
    
                    foreach (ManagementObject WmiObject in Searcher.Get())
                    {
                        Console.WriteLine("{0,-35} {1,-40}","Identifier",WmiObject["Identifier"]);// String
                        Console.WriteLine("{0,-35} {1,-40}","Index",WmiObject["Index"]);// Sint32
                        Console.WriteLine("{0,-35} {1,-40}","InstanceId",WmiObject["InstanceId"]);// String
                        Console.WriteLine("{0,-35} {1,-40}","Max",WmiObject["Max"]);// Real32
                        Console.WriteLine("{0,-35} {1,-40}","Min",WmiObject["Min"]);// Real32
                        Console.WriteLine("{0,-35} {1,-40}","Name",WmiObject["Name"]);// String
                        Console.WriteLine("{0,-35} {1,-40}","Parent",WmiObject["Parent"]);// String
                        Console.WriteLine("{0,-35} {1,-40}","ProcessId",WmiObject["ProcessId"]);// String
                        Console.WriteLine("{0,-35} {1,-40}","SensorType",WmiObject["SensorType"]);// String
                        Console.WriteLine("{0,-35} {1,-40}","Value",WmiObject["Value"]);// Real32
    
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(String.Format("Exception {0} Trace {1}",e.Message,e.StackTrace));
                }
                Console.WriteLine("Press Enter to exit");
                Console.Read();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys having this really simple problem but cant seem to figure out have
Since I'm very new to C programming, I have a probably very simple problem.
I am new to rails development. I have a simple problem but Im stumped
I have a very simple problem. I need to read in the contents of
I have a simple problem but no matter what I try I can't see
I have a very simple problem, but I can't seem to solve it. I
I have a seemingly simple problem, but I can't quite figure out a solution.
it is the problem, i can't undertand anyway. i have the following simple script
I have a simple problem with SQL SERVER charindex function. DECLARE @VAR1 varchar SET
I have a simple problem that I have not been able to find an

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.