0
I'm using vbscript to interact with the WMI classes. I am querying the Win32_GroupUser
class which is defined here https://msdn.microsoft.com/en-us/library/windows/desktop/aa394153%28v=vs.85%29.aspx.
In the definition, it has the following components:
class Win32_GroupUser : CIM_Component
{
Win32_Group REF GroupComponent;
Win32_Account REF PartComponent;
};
My vbscript is as follows:
dim objWMIService, o, obj, test, test1, strComputer
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\cimv2")
set obj = objWMIService.ExecQuery("select partcomponent,groupcomponent from win32_groupuser")
for each o in obj
set test = objWMIService.ReferencesTo(o.groupcomponent)
wscript.echo o.groupcomponent
set test1 = test.itemindex(0)
wscript.echo "test is a "&typename(test)&", test1 is a "&typename(test1)
on error resume next
for each j in test1.methods_ 'list all methods
wscript.echo "Method: "&j.name
next
for each j in test1.properties_ 'list all properties
wscript.echo "Property: "&j.name
next
i = test1.properties_("GroupComponent")
wscript.echo "Groupcomponent is a " & typename(i)
wscript.echo "GroupComponent: "&i
next
The output is
\\COMPUTER\root\cimv2:Win32_Group.Domain="TESTDOMAIN",Name="Schema Admins"
test is a SWbemObjectSet, test1 is a SWbemObjectEx
Property: GroupComponent
Property: PartComponent
Groupcomponent is a String
Groupcomponent: \\COMPUTER\root\cimv2:Win32_NTDomain.Name="Domain: TESTDOMAIN"
However I am having trouble trying to follow the reference to the GroupComponent
; it keeps on coming out as a string and not as a win32_group object, hence I cannot access the properties such as SID etc.
How do I access the groupcomponent as a win32_group object and not as the string?
Not sure why you keep asking the same question repeatedly. Please update the original with new info instead of asking the same thing again.
– Ƭᴇcʜιᴇ007 – 2016-04-29T17:20:21.440@Ƭᴇcʜιᴇ007 the first question was about powershell, this question is about doing the same thing in vbscript. I'd say it's better to ask a new question, than to update the PowerShell question. – SimonS – 2016-04-30T11:22:08.903
I was told to ask it in a new question instead of updating the original with new info; this question is about following references in a wmi object in vb script. The first question you reference is asking about how to link queries in vb script, giving a powershell query as an example. The second question you reference was asking how to get create the correct query in powershell. – A G – 2016-04-30T14:07:02.717
I wonder whether these questions would get better results at [SO]. – Scott – 2016-04-30T18:36:02.393