Can't read registry value using StdRegProv.GetStringValue using java jacob

0

Im trying to use Jacob library

to read registry values from remote machine and im trying to use the GetStringValue

im have the following code

@Test
    public void executeWmiSpecificCommand() {
        //ActiveXComponent wmi = new ActiveXComponent("WbemScripting.SWbemLocator");
        ActiveXComponent mActiveXWMI = new ActiveXComponent("winmgmts:\\\\localhost\\root\\default:StdRegProv");

        int HKEY_LOCAL_MACHINE = 0x80000002;
        Variant baseKey = new Variant(HKEY_LOCAL_MACHINE,true);
        Variant keyName = new Variant("SOFTWARE\\myProgram",true);
        Variant keyValue = new Variant("name",true);
        Variant response = new Variant("",false);

        Variant vCollection = mActiveXWMI.invoke("GetStringValue", baseKey, keyName, keyValue, response);
        EnumVariant enumVariant = new EnumVariant(vCollection.toDispatch());
        Dispatch item = null;
        while (enumVariant.hasMoreElements()) {
            item = enumVariant.nextElement().toDispatch();
            String PropertyName = Dispatch.call(item, "sValue").toString();

            System.out.println(PropertyName );
        }
        ComThread.Release();

    }

I can finally call the method but i always get the following error

com.jacob.com.ComFailException: A COM exception has been encountered: At Invoke of: GetStringValue Description: 80020010 / Invalid callee.

Im pretty sure that im passing the correct parameters and their types but i have no idea for what is this error message

java
ssh
com
wmi
jacob
asked on Stack Overflow Mar 10, 2020 by naoru • edited Mar 13, 2020 by naoru

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0