win32ole and associators

B

Berger, Daniel

Hi all,

Ruby 1.8.2
Windows XP

Are there any known issues with using associators and win32ole?
Consider the following example. Using the first query below, I get four
rows back that look like this:

"\\\\MYDOMAIN\\root\\cimv2:Win32_UserAccount.Domain=3D\"MYDOMAIN\",Name=3D=
\"
System Account\""
"\\\\MYDOMAIN\\root\\cimv2:Win32_Group.Domain=3D\"AD\",Name=3D\"Domain
Admins\""
"\\\\MYDOMAIN\\root\\cimv2:Win32_Group.Domain=3D\"AD\",Name=3D\"Desktop
Admins\""
"\\\\MYDOMAIN\\root\\cimv2:Win32_UserAccount.Domain=3D\"AD\",Name=3D\"djb=
erg
e\""

However, I'd like to get back the actual Win32_UserAccount objects
instead of plain strings. When I try to use associators, I get no
results. What am I doing wrong?

Thanks.

Dan

# assoctest.rb
require "win32ole"
require "socket"

host =3D Socket.gethostname

cs =3D "winmgmts://#{host}/root/cimv2"

# For local groups, you probably want to replace 'MYDOMAIN' with your
host name.

# This returns partcomponent as a String
query =3D "
SELECT *
FROM Win32_GroupUser
WHERE
groupcomponent=3D\"Win32_Group.Domain=3D'MYDOMAIN',Name=3D'Administrators=
'\"
"

# This should return partcomponent as a Win32_UserAccount object, but
instead returns nothing
#query =3D "
# associators of {Win32_Group.Domain=3D'MYDOMAIN',
Name=3D'Administrators'}
# where resultclass =3D Win32_UserAccount AssocClass =3D =
Win32_GroupUser
#"

wmi =3D WIN32OLE.connect(cs)
wmi.execquery(query).each{ |m|
p m.partcomponent
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top