Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Tue, 6 May 2008 12:47:05 +0100,    group: microsoft.public.win32.programmer.wmi        back       


Schema Query - Top Level Classes Only   
Hi,

I'm trying to get a list of all "top level" classes from a given namespace, 
e.g. connect to CimV2 then issue:

SELECT * FROM Meta_Class

The problem is that I get nearly 1000 results, I assume it's giving me all 
sub-classes as well. Is there a way to get only the top level classes?

-- 
Gerry Hickman
London (UK)
date: Tue, 6 May 2008 12:47:05 +0100   author:   Gerry Hickman am

RE: Schema Query - Top Level Classes Only   
"Gerry Hickman" wrote:

> Hi,
> 
> I'm trying to get a list of all "top level" classes from a given namespace, 
> e.g. connect to CimV2 then issue:
> 
> SELECT * FROM Meta_Class
> 
> The problem is that I get nearly 1000 results, I assume it's giving me all 
> sub-classes as well. Is there a way to get only the top level classes?
> 
> -- 
> Gerry Hickman
> London (UK) 
> 
> 


"Select * From Meta_Class Where __Superclass Is Null"


-- 
urkec
date: Tue, 6 May 2008 07:50:02 -0700   author:   urkec

Re: Schema Query - Top Level Classes Only   
Hi urkec,

>> SELECT * FROM Meta_Class
>>
>> The problem is that I get nearly 1000 results, I assume it's giving me all 
>> sub-classes as well. Is there a way to get only the top level classes?

> "Select * From Meta_Class Where __Superclass Is Null"

Great, that seems to work!

-- 
Gerry Hickman (London UK)
date: Tue, 06 May 2008 20:55:53 +0100   author:   Gerry Hickman am

Re: Schema Query - Top Level Classes Only   
>> "Select * From Meta_Class Where __Superclass Is Null"
> 
> Great, that seems to work!

But what I really want to do is in code, like this:

var sClass = "Win32_DiskDrive";
var oClassDef = oSvc.Get(sClass);
var cSubClasses = oClassDef.Subclasses_();
showMembers(cSubClasses);

this would show names of Subclasses of Win32_DiskDrive, but I want to 
get top level classes from the Namespace, something like:

var sClass = "";			// start from root
var oClassDef = oSvc.Get(sClass);
var cSubClasses = oClassDef.Subclasses_();
showMembers(cSubClasses);

-- 
Gerry Hickman (London UK)
date: Tue, 06 May 2008 23:11:46 +0100   author:   Gerry Hickman am

Re: Schema Query - Top Level Classes Only   
Hi Gerry,

Thanks for your feedback. 

I am not sure if I have understood you completely. Is your problem 
resolved? If not, can you tell me why urkec's reply does not meet your 
need? Can you help to explain your problem in more details? 

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
date: Wed, 07 May 2008 03:53:17 GMT   author:   (Jeffrey Tan[MSFT])

Re: Schema Query - Top Level Classes Only   
Hi Jeffrey,

> I am not sure if I have understood you completely. Is your problem 
> resolved? If not, can you tell me why urkec's reply does not meet your 
> need? Can you help to explain your problem in more details?

Urkec's reply solves the problem in the context of using a query, but I 
want to use the SubClasses() method instead to get only 
top-level-classes from a Namespace, see my previous post for code 
snippets that demonstrate this.

-- 
Gerry Hickman (London UK)
date: Wed, 07 May 2008 23:32:36 +0100   author:   Gerry Hickman am

Re: Schema Query - Top Level Classes Only   
"Gerry Hickman" wrote:

> Hi Jeffrey,
> 
> > I am not sure if I have understood you completely. Is your problem 
> > resolved? If not, can you tell me why urkec's reply does not meet your 
> > need? Can you help to explain your problem in more details?
> 
> Urkec's reply solves the problem in the context of using a query, but I 
> want to use the SubClasses() method instead to get only 
> top-level-classes from a Namespace, see my previous post for code 
> snippets that demonstrate this.
> 
> -- 
> Gerry Hickman (London UK)
> 

Instead of SWbemObject.Subclasses_  you would need to use 
SWbemServices.SubclassesOf with wbemQueryFlagShallow  flag:

var wbemQueryFlagShallow = 1
var cSubClasses = oSvc.SubclassesOf("", wbemQueryFlagShallow)

but you get the same result using SWbemServices.ExecQuery with the query I 
posted:

var cSubClasses1 = oSvc.ExecQuery("Select * From Meta_Class Where 
__Superclass Is Null")



-- 
urkec
date: Thu, 8 May 2008 08:25:04 -0700   author:   urkec

Re: Schema Query - Top Level Classes Only   
Hi Gerry,

Thanks for your feedback. Oh, it seems that urkec has provided the correct 
answer to you. Thank you urkec!

Actually, it's not clear to me why you prefer to not use the meta_class 
query, but you can accomplish the same thing by specifying the Shallow flag:

const wbemQueryFlagShallow = 1

set osvc = getobject("winmgmts:root\cimv2")

for each ocls in osvc.subclassesof("", wbemQueryFlagShallow)
	wscript.echo ocls.path_.class
next

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
date: Fri, 09 May 2008 01:53:25 GMT   author:   (Jeffrey Tan[MSFT])

Re: Schema Query - Top Level Classes Only   
Thanks Jeffrey, urkec,

This answers my question.

The reason I wanted to do it by method calls, is so that I could use 
recursion to enum the classes and sub-classes (starting from any point 
in the tree). The WQL query is less suited to this.

Jeffrey Tan[MSFT] wrote:
> Hi Gerry,
> 
> Thanks for your feedback. Oh, it seems that urkec has provided the correct 
> answer to you. Thank you urkec!
> 
> Actually, it's not clear to me why you prefer to not use the meta_class 
> query, but you can accomplish the same thing by specifying the Shallow flag:
> 
> const wbemQueryFlagShallow = 1
> 
> set osvc = getobject("winmgmts:root\cimv2")
> 
> for each ocls in osvc.subclassesof("", wbemQueryFlagShallow)
> 	wscript.echo ocls.path_.class
> next
> 
> Thanks.
> 
> Best regards,
> Jeffrey Tan
> Microsoft Online Community Support
> =========================================
> Delighting our customers is our #1 priority. We welcome your comments and 
> suggestions about how we can improve the support we provide to you. Please 
> feel free to let my manager know what you think of the level of service 
> provided. You can send feedback directly to my manager at: 
> msdnmg@microsoft.com.
> 
> This posting is provided "AS IS" with no warranties, and confers no rights.
> 


-- 
Gerry Hickman (London UK)
date: Mon, 12 May 2008 22:14:37 +0100   author:   Gerry Hickman am

Re: Schema Query - Top Level Classes Only   
Hi Gerry,

Thanks for your confirmation. 

Ok, if you need further help, please feel free to post, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
date: Tue, 13 May 2008 12:42:31 GMT   author:   (Jeffrey Tan[MSFT])

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us