This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

List all local group members and add members to the local group on a remote machine using JAVA COM  RSS feed

giby mathew
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Does anyone know how to view all the members of a local group like 'Remote Desktop Users' and also add some members to the the group using java com? I tried some java code which was able to connect to the server but was not able to retrieve the member list. I am getting the error ' Can't map name to dispid: InstancesOf'. Please help guys.

public static void connectMachine()
ActiveXComponent wmi = new ActiveXComponent("WbemScripting.SWbemLocator");

Variant variantParameters[] = new Variant[4];
variantParameters[0] = new Variant(IP);
variantParameters[1] = new Variant("root\\cimv2");
variantParameters[2] = new Variant(adminUserName);
variantParameters[3] = new Variant(AdminPassword);
ActiveXComponent axWMI;
Variant conRet = wmi.invoke("ConnectServer", variantParameters);
axWMI = new ActiveXComponent(conRet.toDispatch());
Variant instances = wmi.invoke("InstancesOf", "Win32_Group");
Enumeration<Variant> en = new EnumVariant(instances.getDispatch());
while (en.hasMoreElements())
ActiveXComponent bb = new ActiveXComponent(en.nextElement().getDispatch());
catch (ComFailException e)
axWMI = null;
if (axWMI == null)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!