WMI Methods

Started by bettman, April 14, 2016, 10:13:45 AM

Previous topic - Next topic

bettman


Greetings,

Could you briefly outline how to invoke a method from a WMI class? Specifcally I am trying to use the GetKeyProtectorNumericalPassword method of the Win32_EncryptableVolume class to determine what recovery password is for an encrypted OS drive on a workstation
Any help would be appreciated.

Thank you.

td

The Tech Database has several sections devoted to WMI.  It is probably the most covered topic in the database.  You might want to try a Tech Database search on the term WMI and scroll down the results for examples that you may find useful. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bettman

I looked at it but I must admit, my understanding of WMI is limited. I couldn't locate anything which describes the calling of a method however.

td

Almost every WMI example in the Tech Database calls at least one method.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bettman

Could you provide a specific example of one that does?

td

Pick almost any WMI example in the Tech Database.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bettman


td

WMI objects, methods and properties are nothing more the COM Automation objects, methods and properties.  If you don't know anything about WinBatch COM Automation support, you should start by reading the COM Help File section of your Consolidated WIL Help file.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bettman

All I asked was for a specific example. A simple URL to some sample code would have sufficed

td

Quote from: td on April 14, 2016, 02:15:26 PM
Had one of those something-isn't-quite-right-someplace moments.  I believe you are out of luck because the  'KeyProtectorNumericalPassword' method name is 32 characters long so you can't call it from WinBatch directly.  You would have to use something like use CLR hosting and write an  embedded c# script that created a class wrapper that called the actual method that and compile in a WinBatch script.  You could then call the CLR wrapper method from the mainline script.  Ugly at best.

A major, embarrassing  error on my part.  The method name length is not a problem here.  WIL supports COM Automation methods of any name length as long as you can fit the object variable, name and parameters on a single line.  The method name length limit was removed many years ago...

The original post stating otherwise has been removed to hopefully prevent any future confusion on the subject.

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Quote from: bettman on April 14, 2016, 11:33:52 AM
All I asked was for a specific example. A simple URL to some sample code would have sufficed

You asked the identical question about another method on the same WMI class object on  September 10, 2014.  The information provided in the responses can be applied to the 'GetKeyProtectorNumericalPassword' method without to much effort.  The entire topic is still available on this forum, if you don't recall it.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade