Author Topic: WMI Methods  (Read 8381 times)

bettman

  • Newbie
  • *
  • Posts: 41
WMI Methods
« on: April 14, 2016, 10:13:45 am »

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

  • Tech Support
  • *****
  • Posts: 3490
    • WinBatch
Re: WMI Methods
« Reply #1 on: April 14, 2016, 10:55:07 am »
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

  • Newbie
  • *
  • Posts: 41
Re: WMI Methods
« Reply #2 on: April 14, 2016, 10:58:23 am »
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

  • Tech Support
  • *****
  • Posts: 3490
    • WinBatch
Re: WMI Methods
« Reply #3 on: April 14, 2016, 11:00:49 am »
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

  • Newbie
  • *
  • Posts: 41
Re: WMI Methods
« Reply #4 on: April 14, 2016, 11:06:38 am »
Could you provide a specific example of one that does?

td

  • Tech Support
  • *****
  • Posts: 3490
    • WinBatch
Re: WMI Methods
« Reply #5 on: April 14, 2016, 11:15:48 am »
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

  • Newbie
  • *
  • Posts: 41
Re: WMI Methods
« Reply #6 on: April 14, 2016, 11:19:37 am »
Sorry for asking

td

  • Tech Support
  • *****
  • Posts: 3490
    • WinBatch
Re: WMI Methods
« Reply #7 on: April 14, 2016, 11:31:02 am »
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

  • Newbie
  • *
  • Posts: 41
Re: WMI Methods
« Reply #8 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

td

  • Tech Support
  • *****
  • Posts: 3490
    • WinBatch
Re: WMI Methods
« Reply #9 on: April 15, 2016, 08:16:32 am »
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

  • Tech Support
  • *****
  • Posts: 3490
    • WinBatch
Re: WMI Methods
« Reply #10 on: April 15, 2016, 08:27:22 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