locked
Win32_Tpm Clear Method RRS feed

  • Question

  • Hi ,

    I'm trying to use the Clear method of Win32_Tpm Class , using the wmi code creator :

    using System;
    using System.Management;
    using System.Windows.Forms;

    namespace WMISample
    {
        public class CallWMIMethod
        {
            public static void Main()
            {
                try
                {
                    ManagementObject classInstance =
                        new ManagementObject("root\\CIMV2\\Security\\MicrosoftTpm",
                        "Win32_Tpm.ReplaceKeyPropery='ReplaceKeyPropertyValue'",
                        null);

                    // Obtain in-parameters for the method
                    ManagementBaseObject inParams =
                        classInstance.GetMethodParameters("Clear");

                    // Add the input parameters.
                    inParams["OwnerAuth"] =  "";

                    // Execute the method and obtain the return values.
                    ManagementBaseObject outParams =
                        classInstance.InvokeMethod("Clear", inParams, null);

                    // List outParams
                    Console.WriteLine("Out parameters:");
                    Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);
                }
                catch(ManagementException err)
                {
                    MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
                }
            }
        }
    }

    but it always returns an error "Invalid Class" , I choose to leave the "OwnerAuth" empty as MSDN suggests:

    "The OwnerAuth parameter is read from the registry if none is provided"

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa376420(v=vs.85).aspx

    Does Anyone has an idea ?

    Thanks.

    Monday, April 28, 2014 8:10 AM