none
Create Class WMI with registry path RRS feed

  • Question

  • Hello,

    I'm a little bit lost, for example I have a registry "HKLM\Sofware\Version"

    Somebody knows, how to create a new WMI Class, ( with proprety version for example ) associated to the registry key version ?

    For when i want to ask my new wmi class / property, the script back to me the key value "Version"

    My problem is i know how to create WMI class but not the association with a registry key

    Thank you


    • Edited by Twenty94470 Thursday, September 8, 2016 2:55 PM
    Thursday, September 8, 2016 2:55 PM

Answers

  • Hi Twenty,

    this is possible, and there is a good blog post explaining this. Scroll down to the chapter "Roll Your Own Class". It's an old issue for reading the installed products on a computer, as it is not safe to use win32_product.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Twenty94470 Friday, September 9, 2016 12:42 PM
    Friday, September 9, 2016 8:44 AM

All replies

  • What does a WMI class have to do with a registry subkey?

    Avoid the XY problem - tell your question, not how you think it should be done.


    -- Bill Stewart [Bill_Stewart]

    Thursday, September 8, 2016 3:24 PM
    Moderator
  • Or ---

    Get-ItemProperty HKLM:\Software\Microsoft\Cryptography -Name MachineGuid
    Get-ItemProperty HKLM:\Software\SomeCo\App1 -Name Version


    \_(ツ)_/

    Thursday, September 8, 2016 3:29 PM
  • As I sad i'm a little bit lost :)

    In my last company I saw a colleague make a wql query on wmi class, the property had value as 1

    Then he changed the value of the registry key to 2

    And the same wql query as now the result "2"

    In he's query, he never targeted the path of the registry key but just the property of the wmi class

    So I concluded that we can associate a property's wmi class with a registry key, but i didn't find example and i can't reproduce what he did

    • Edited by Twenty94470 Thursday, September 8, 2016 4:07 PM
    Thursday, September 8, 2016 4:06 PM
  • The code I posted does exactly that in PowerShell.

    We seldom use WMI for registry access. It is not the best or easiest way to do it.


    \_(ツ)_/

    Thursday, September 8, 2016 4:09 PM
  • WMI can be used to modify a registry value, but it's not the only way.

    You're going to need to be more specific and give an actual use case.


    -- Bill Stewart [Bill_Stewart]

    Thursday, September 8, 2016 8:55 PM
    Moderator
  • Pictures will be more speaking

    I have Registry Key

    I do a query to see all property in myClass, but i never change anything

    The property back to me the value of my registry key, both are link ?


    I manually change the value of this registry key

    And the same query back to me new value.

    So i would like to know when i create wmi class and proprety, how to link my proprety to query the value of my registry key like my example ?

    Thank you

    Friday, September 9, 2016 8:07 AM
  • Hi Twenty,

    this is possible, and there is a good blog post explaining this. Scroll down to the chapter "Roll Your Own Class". It's an old issue for reading the installed products on a computer, as it is not safe to use win32_product.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Twenty94470 Friday, September 9, 2016 12:42 PM
    Friday, September 9, 2016 8:44 AM
  • Hi Twenty,

    this is possible, and there is a good blog post explaining this. Scroll down to the chapter "Roll Your Own Class". It's an old issue for reading the installed products on a computer, as it is not safe to use win32_product.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Hi Fred,

    Thank you for this article, i will do some test :) 

    Regards,

    Friday, September 9, 2016 12:42 PM
  • Are you sure you want to create a class? Or do you just want to set a registry value?

    The question is not at all clear.


    -- Bill Stewart [Bill_Stewart]

    Friday, September 9, 2016 2:12 PM
    Moderator
  • Yes, a new custom wmi class with property link to registry key.

    Sorry if I was not clear enough ( my english is not perfect :p ) 

    Thank you for all your help :)

    Friday, September 9, 2016 2:30 PM
  • Why do you need to do that? What problem are you solving?

    -- Bill Stewart [Bill_Stewart]

    Friday, September 9, 2016 3:58 PM
    Moderator