WMI - how to use managament class methods 
Author Message
 WMI - how to use managament class methods

What is the correct syntax to invoke a method out of a management class?
Note, the info relating to this method can be found in
ms-help://MS.VSCC/MS.MSDNVS/wmisdk/r_32os6_79gu.htm

I tried the following :
System.Management.ManagementClass mc = new
ManagementClass("Win32_WindowsProductActivation");

returnedValue = (uint32) mc.InvokeMethod("GetInstallationID",null);

I got the following error :

An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll

Additional information: Invalid parameter(s).



Sun, 29 Aug 2004 00:38:17 GMT  
 WMI - how to use managament class methods
InvokeMethod takes three args, try this:

    ...
    string InstallationID = null;
    ManagementBaseObject inParams = null;
    ManagementBaseObject outParams = mc.InvokeMethod("GetInstallationID", inParams, null);
    InstallationID = System.Convert.ToString(outParams.Properties["InstallationID"].Value);
    if(Convert.ToUInt32(outParams.Properties["ReturnValue"].Value) == 0)
        ....// success & activation required property is 1
    else
        .... // No activation required or failure

Willy.

Quote:

> What is the correct syntax to invoke a method out of a management class?
> Note, the info relating to this method can be found in
> ms-help://MS.VSCC/MS.MSDNVS/wmisdk/r_32os6_79gu.htm

> I tried the following :
> System.Management.ManagementClass mc = new
> ManagementClass("Win32_WindowsProductActivation");

> returnedValue = (uint32) mc.InvokeMethod("GetInstallationID",null);

> I got the following error :

> An unhandled exception of type 'System.Management.ManagementException'
> occurred in system.management.dll

> Additional information: Invalid parameter(s).



Sun, 29 Aug 2004 23:43:40 GMT  
 WMI - how to use managament class methods
Thanks for the help, but it still does not work.

I get this error :
An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll

Additional information: Invalid method parameter(s).
It happens during the InvokeMethod call.
I tried the following thinking it might be the options that were wrong.
System.Management.ManagementClass mc = new
ManagementClass("Win32_WindowsProductActivation");

string InstallationID = null;

ManagementBaseObject inParams = null;

System.Management.InvokeMethodOptions options = new InvokeMethodOptions();

ManagementBaseObject outParams = mc.InvokeMethod("GetInstallationID",
inParams, options);

InstallationID =
System.Convert.ToString(outParams.Properties["InstallationID"].Value);

But I get the same error with this code as yours. Were you able to execute
the sample code you sent me? If so then the problem might be on my end. If
you did not test it, maybe it is related to the inParams object??
Thanks a lot for helping me!



Quote:
> InvokeMethod takes three args, try this:

>     ...
>     string InstallationID = null;
>     ManagementBaseObject inParams = null;
>     ManagementBaseObject outParams = mc.InvokeMethod("GetInstallationID",
inParams, null);
>     InstallationID =

System.Convert.ToString(outParams.Properties["InstallationID"].Value);
Quote:
>     if(Convert.ToUInt32(outParams.Properties["ReturnValue"].Value) == 0)
>         ....// success & activation required property is 1
>     else
>         .... // No activation required or failure

> Willy.




Quote:
> > What is the correct syntax to invoke a method out of a management class?
> > Note, the info relating to this method can be found in
> > ms-help://MS.VSCC/MS.MSDNVS/wmisdk/r_32os6_79gu.htm

> > I tried the following :
> > System.Management.ManagementClass mc = new
> > ManagementClass("Win32_WindowsProductActivation");

> > returnedValue = (uint32) mc.InvokeMethod("GetInstallationID",null);

> > I got the following error :

> > An unhandled exception of type 'System.Management.ManagementException'
> > occurred in system.management.dll

> > Additional information: Invalid parameter(s).



Mon, 30 Aug 2004 00:43:04 GMT  
 WMI - how to use managament class methods
No it doesn't work for me  either.
Running wbemtest returns HR = 0x8004102f  (Invalid parameters) , so this looks like a bug in the Windows Product Activation (WPA)
provider.

Willy.

Quote:

> Thanks for the help, but it still does not work.

> I get this error :
> An unhandled exception of type 'System.Management.ManagementException'
> occurred in system.management.dll

> Additional information: Invalid method parameter(s).
> It happens during the InvokeMethod call.
> I tried the following thinking it might be the options that were wrong.
> System.Management.ManagementClass mc = new
> ManagementClass("Win32_WindowsProductActivation");

> string InstallationID = null;

> ManagementBaseObject inParams = null;

> System.Management.InvokeMethodOptions options = new InvokeMethodOptions();

> ManagementBaseObject outParams = mc.InvokeMethod("GetInstallationID",
> inParams, options);

> InstallationID =
> System.Convert.ToString(outParams.Properties["InstallationID"].Value);

> But I get the same error with this code as yours. Were you able to execute
> the sample code you sent me? If so then the problem might be on my end. If
> you did not test it, maybe it is related to the inParams object??
> Thanks a lot for helping me!



> > InvokeMethod takes three args, try this:

> >     ...
> >     string InstallationID = null;
> >     ManagementBaseObject inParams = null;
> >     ManagementBaseObject outParams = mc.InvokeMethod("GetInstallationID",
> inParams, null);
> >     InstallationID =
> System.Convert.ToString(outParams.Properties["InstallationID"].Value);
> >     if(Convert.ToUInt32(outParams.Properties["ReturnValue"].Value) == 0)
> >         ....// success & activation required property is 1
> >     else
> >         .... // No activation required or failure

> > Willy.



> > > What is the correct syntax to invoke a method out of a management class?
> > > Note, the info relating to this method can be found in
> > > ms-help://MS.VSCC/MS.MSDNVS/wmisdk/r_32os6_79gu.htm

> > > I tried the following :
> > > System.Management.ManagementClass mc = new
> > > ManagementClass("Win32_WindowsProductActivation");

> > > returnedValue = (uint32) mc.InvokeMethod("GetInstallationID",null);

> > > I got the following error :

> > > An unhandled exception of type 'System.Management.ManagementException'
> > > occurred in system.management.dll

> > > Additional information: Invalid parameter(s).



Mon, 30 Aug 2004 02:59:01 GMT  
 WMI - how to use managament class methods
If there was a parameter to pass to the method, how do you go about setting
a value to the inParams? In the sample you sent me, you set the param to
null, if a WMI method would need an input parameter, how does it work?

ManagementBaseObject inParams = ?????;



Quote:
> No it doesn't work for me  either.
> Running wbemtest returns HR = 0x8004102f  (Invalid parameters) , so this

looks like a bug in the Windows Product Activation (WPA)
Quote:
> provider.

> Willy.




Quote:
> > Thanks for the help, but it still does not work.

> > I get this error :
> > An unhandled exception of type 'System.Management.ManagementException'
> > occurred in system.management.dll

> > Additional information: Invalid method parameter(s).
> > It happens during the InvokeMethod call.
> > I tried the following thinking it might be the options that were wrong.
> > System.Management.ManagementClass mc = new
> > ManagementClass("Win32_WindowsProductActivation");

> > string InstallationID = null;

> > ManagementBaseObject inParams = null;

> > System.Management.InvokeMethodOptions options = new

InvokeMethodOptions();

- Show quoted text -

Quote:

> > ManagementBaseObject outParams = mc.InvokeMethod("GetInstallationID",
> > inParams, options);

> > InstallationID =
> > System.Convert.ToString(outParams.Properties["InstallationID"].Value);

> > But I get the same error with this code as yours. Were you able to
execute
> > the sample code you sent me? If so then the problem might be on my end.
If
> > you did not test it, maybe it is related to the inParams object??
> > Thanks a lot for helping me!


message

> > > InvokeMethod takes three args, try this:

> > >     ...
> > >     string InstallationID = null;
> > >     ManagementBaseObject inParams = null;
> > >     ManagementBaseObject outParams =

mc.InvokeMethod("GetInstallationID",

- Show quoted text -

Quote:
> > inParams, null);
> > >     InstallationID =
> > System.Convert.ToString(outParams.Properties["InstallationID"].Value);
> > >     if(Convert.ToUInt32(outParams.Properties["ReturnValue"].Value) ==
0)
> > >         ....// success & activation required property is 1
> > >     else
> > >         .... // No activation required or failure

> > > Willy.



> > > > What is the correct syntax to invoke a method out of a management
class?
> > > > Note, the info relating to this method can be found in
> > > > ms-help://MS.VSCC/MS.MSDNVS/wmisdk/r_32os6_79gu.htm

> > > > I tried the following :
> > > > System.Management.ManagementClass mc = new
> > > > ManagementClass("Win32_WindowsProductActivation");

> > > > returnedValue = (uint32) mc.InvokeMethod("GetInstallationID",null);

> > > > I got the following error :

> > > > An unhandled exception of type

'System.Management.ManagementException'

- Show quoted text -

Quote:
> > > > occurred in system.management.dll

> > > > Additional information: Invalid parameter(s).



Mon, 30 Aug 2004 22:00:44 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. execute WMI method

2. WMI Instrumented object methods not exposed

3. WMI - WMI Login Cotrol causes exception when destroying

4. Advice on using a class method to set its own property

5. MEMORY LEAK using CDaoRecordset Class and AddNew() method

6. Question about using ReadString() method in CArchive class

7. Using general API in MFC class methods

8. Using methods of differemt classes

9. using list class (clear method)

10. how can I call a method on a class using reflection

11. Using the AddStrip method on the ImageCollection class

12. which WMI class for installed software

 

 
Powered by phpBB® Forum Software