Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


WMI Collection Object

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3147
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> WMI Collection Object
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 WMI Collection Object - 5/27/2005 4:53:11 PM   
  macer

 

Posts: 1
Score: 0
Joined: 5/27/2005
From:
Status: offline
Hello

I am trying to determine the number of instances running on a computer of a particular application. Below is the code I'm using to determine the number of Excel instances, but it returns an error when I attempt to get the number of items in the collection.

Any suggestions?

Thanks
Macer

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
strQuery = "Select * from Win32_Process where Name='excel.exe'"
Set colItems = objWMIService.ExecQuery(strQuery,,48)

iNum = colItems.count

WScript.Echo iNum

One solution would be to count each instance in the collection, but I was wanting to know how to get the count property to work.

For Each objItem in colItems
iNum = iNum + 1
Next

WScript.Echo iNum
 
 
Post #: 1
 
 Re: WMI Collection Object - 5/28/2005 2:36:52 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I don't believe there is a count property for Win32_Process class.

(in reply to macer)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> WMI Collection Object Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts