开发者

Calling WMI methods via a WQL query

I'd like to call a static method via WMI using WQL (bas开发者_高级运维ically the equivalent of the "Execute Method" button in wbemtest.exe), but I'm having trouble finding syntax examples.

I have a custom WMI provider named "HelloWmi" with the following method:

[ManagementTask]
public static string getVersion()
{
    return "1.4.2";
}

In wbemtest I can click the "Execute Method" button, enter "HelloWmi" as the object path, and I'm presented with a combobox of methods to execute. Similarly, I can run the following in windows:

C:\Windows\system32>wmic /namespace:\\root\Test path HelloWmi call getVersion
Executing (HelloWmi)->getVersion()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
    ReturnValue = "1.4.2";
};

However, for this project I'm not using the standard WMIC tool for windows, but accessing WMI remotely via the WMIC package for ubuntu, which doesn't seem to support the aliases that WMIC for windows has.

Is there any way to call WMI methods using just a WQL query?


No monica, is not possible execute a WMI method from a WQL sentence.the wmi querys are just for retrieve information about wmi classes and properties, not for execute wmi methods. for more information about execute wmi methods you can check these links

  • Calling a Provider Method
  • How To: Execute a WMI Method
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜