Generic Failure

Help
2012-10-19
2013-05-20
  • Dan Dubinsky
    Dan Dubinsky
    2012-10-19

    Hi All,

    I'm new to Jacob. I came across a code snippet on the web but when I run it I get:

    com.jacob.com.ComFailException: Invoke of: ExecQuery
    Source: SWbemServicesEx
    Description: Generic failure
    at com.jacob.com.Dispatch.invokev(Native Method)

    The exception has an error code in it: -2147217407

    This is the snippet. It failed at the invoke:

    String host = "localhost";
    String connectStr = String.format("winmgmts:\\\\%s\\root\\CIMV2", host);
    String query = "SELECT * FROM Win32_Service WHERE started = 1";
    ActiveXComponent axWMI = new ActiveXComponent(connectStr);
    Variant vCollection = axWMI.invoke("ExecQuery", new Variant(query));

    Anybody have any ideas?

    Thanks