Optimization of WSH & General question 
Author Message
 Optimization of WSH & General question

1. The standard example using VBScript is:

Set oWMI = GetObject(sWinMgmt)

  for each CPU in oWMI.InstancesOf("Win32_Processor")
    sCPUInfo = sCPUInfo _
        & "CPU Manufacturer" & chr(9) & CPU.Name & vbCrLf _
        & "CPU Type" & chr(9) & chr(9)  & CPU.Caption & vbCrLf _
        & "CPU Speed" & chr(9) & chr(9)  & CPU.CurrentClockSpeed

  next

It would seem faster if I could do something like the following:

  CPUName = CPU.Name

Is this possible?

2. I also have a general question regarding WSH/WMI.  I understand the
fact that classes are defined and when scripting, access information
via WinMgmt.exe but where is this information actually stored?  In a
file?  I know the registry is file based but what about information
regarding WMI?  Just curious...

Thanks in advance.



Thu, 23 Sep 2004 11:25:29 GMT  
 Optimization of WSH & General question
Here's a couple of answers....

(1) You can't exactly do that because everything is being returned as an array.  In the case where you are certain that you have only 1 CPU, its index is zero - but it is still in an array of CPUs (just an array with 1 element).

(2) I'm not completely clear on the details of how WMI works.  Internally I know that many of the items it queries are findable from low-level API calls on Windows; I'm not positive that WMI uses that route for anything it does, but it actually appears to dynamically query the system to find state information.  It doesn't keep a cached copy of all of that information in a file somewhere; WMI is a mechanism for getting the information from the "live" hardware and software in real time (with a short wait, of course).

Quote:

> 1. The standard example using vbscript is:

> Set oWMI = GetObject(sWinMgmt)

>   for each CPU in oWMI.InstancesOf("Win32_Processor")
>     sCPUInfo = sCPUInfo _
>         & "CPU Manufacturer" & chr(9) & CPU.Name & vbCrLf _
>         & "CPU Type" & chr(9) & chr(9)  & CPU.Caption & vbCrLf _
>         & "CPU Speed" & chr(9) & chr(9)  & CPU.CurrentClockSpeed

>   next

> It would seem faster if I could do something like the following:

>   CPUName = CPU.Name

> Is this possible?

> 2. I also have a general question regarding WSH/WMI.  I understand the
> fact that classes are defined and when scripting, access information
> via WinMgmt.exe but where is this information actually stored?  In a
> file?  I know the registry is file based but what about information
> regarding WMI?  Just curious...

> Thanks in advance.



Thu, 23 Sep 2004 11:40:55 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. WSH General OS Question

2. General newbie question

3. general postscript questions

4. General Question about Internet Servers

5. General scripting question

6. General VB Questions

7. General Question

8. general vbs/vb question about objects

9. wshini / general control question

10. General newbie questions

11. General Questions 10 - Problems debugging

12. Trouble with this script and a general question

 

 
Powered by phpBB® Forum Software