Reputation: 33
I'm new to scripting and programming.
In the following and similar scripts, I noticed that there exists a 'objOperatingSystem' that is referred to in the 'For Each' loop. I understand that 'colSettings' is a variable that contains the WMI collection, but where does the 'objOperatingSystem' come from ?
Pls help. Thanks!!!
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
Wscript.Echo "Available Physical Memory: " & _
objOperatingSystem.FreePhysicalMemory
Next
Upvotes: 3
Views: 398
Reputation: 1
It's vb script. And it's looking into the operating system object thru WMI to see available memory. it's part on the winmgmts (windows management) object. Use a neat tool called WMI creator and surf all the cool wmi's on your computer. It's is just a variable created to hold the object it's looking for in WMI and then iterates thru it "for each" time.
Upvotes: 0
Reputation: 3375
objOperatingSystem
is a variable. For Each
declared it. Basically, for every item in colSettings
a variable named objOperatingSystem
will be set to the current item, and the body of the for loop executed.
Upvotes: 2