EDN Admin
Well-known member
Hello,
I didnt find a WMI discussion board, so Im hoping that someone will point me to a more appropriate area for my question...
I am trying to execute a method in WMI class that was made up in our in-house .MOF file. Depending on what ManagementClass.InvokeMethod overload I try to use, I get different errors. My C# code is below:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Management;
<span style="color:Blue; namespace ConsoleApplication1
{
<span style="color:Blue; class clsMain
{
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; void Main()
{
ManagementPath p = <span style="color:Blue; new ManagementPath(<span style="color:#A31515; @"\localhostrootwmi:ACPITest_MULong");
ManagementClass c = <span style="color:Blue; new ManagementClass(p);
ManagementBaseObject inParams = c.GetMethodParameters(<span style="color:#A31515; "SetULong");
UInt32 i = 111;
inParams[<span style="color:#A31515; "Data"] = i;
<span style="color:Green; // BELOW CALL ERRORS WITH "Invalid Method Parameters"
ManagementBaseObject outParams = c.InvokeMethod(<span style="color:#A31515; "SetULong", inParams, <span style="color:Blue; null);
Console.WriteLine(outParams.Properties[<span style="color:#A31515; "Data"].Value);
<span style="color:Green; // ANOTHER VERSION - InvokeMethod() ERRORS WITH "Input String was not in correct format"
<span style="color:Green; //object[] args = { "Data", i };
<span style="color:Green; //string s = "SetULong";
<span style="color:Green; //object o = c.InvokeMethod(s, args);
}
}
}
[/code]
To my knowledge, the MOF file is correct, but I am trying to get verification from an overseas colleague who was apparently the author of the MOF.
The class is in the rootwmi namespace and it appears as such in my CIM studio. The Class does contain two methods: GetULong and SetULong. I verified the parameters for the SetULong method:
Name: Data
Type: uint32
value: <empty>
return value: void
I have given the appropriate permissions via the wmimgmt.msc snapin and have tried executing this .exe in the command prompt as an administrator - no luck.
Please help - I have spent a significant amount of time on this issue and am getting nowhere. Thanks in advance.
View the full article
I didnt find a WMI discussion board, so Im hoping that someone will point me to a more appropriate area for my question...
I am trying to execute a method in WMI class that was made up in our in-house .MOF file. Depending on what ManagementClass.InvokeMethod overload I try to use, I get different errors. My C# code is below:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Management;
<span style="color:Blue; namespace ConsoleApplication1
{
<span style="color:Blue; class clsMain
{
<span style="color:Blue; public <span style="color:Blue; static <span style="color:Blue; void Main()
{
ManagementPath p = <span style="color:Blue; new ManagementPath(<span style="color:#A31515; @"\localhostrootwmi:ACPITest_MULong");
ManagementClass c = <span style="color:Blue; new ManagementClass(p);
ManagementBaseObject inParams = c.GetMethodParameters(<span style="color:#A31515; "SetULong");
UInt32 i = 111;
inParams[<span style="color:#A31515; "Data"] = i;
<span style="color:Green; // BELOW CALL ERRORS WITH "Invalid Method Parameters"
ManagementBaseObject outParams = c.InvokeMethod(<span style="color:#A31515; "SetULong", inParams, <span style="color:Blue; null);
Console.WriteLine(outParams.Properties[<span style="color:#A31515; "Data"].Value);
<span style="color:Green; // ANOTHER VERSION - InvokeMethod() ERRORS WITH "Input String was not in correct format"
<span style="color:Green; //object[] args = { "Data", i };
<span style="color:Green; //string s = "SetULong";
<span style="color:Green; //object o = c.InvokeMethod(s, args);
}
}
}
[/code]
To my knowledge, the MOF file is correct, but I am trying to get verification from an overseas colleague who was apparently the author of the MOF.
The class is in the rootwmi namespace and it appears as such in my CIM studio. The Class does contain two methods: GetULong and SetULong. I verified the parameters for the SetULong method:
Name: Data
Type: uint32
value: <empty>
return value: void
I have given the appropriate permissions via the wmimgmt.msc snapin and have tried executing this .exe in the command prompt as an administrator - no luck.
Please help - I have spent a significant amount of time on this issue and am getting nowhere. Thanks in advance.
View the full article