Hi guys sorry not to have put more of the code and thansk Richard, you
suggestion works.
Here is the code:
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer,"root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_LogicalDisk",,48)
For Each objItem in colItems
if (objItem.Name = "C:") Or (objItem.Name = "D:") then
Freespace = objItem.FreeSpace
'Wscript.Echo "-----------------------------------"
'Wscript.Echo "Win32_LogicalDisk instance"
'Wscript.Echo "-----------------------------------"
Wscript.Echo "Disk Drive: " & objItem.Name
'Wscript.Echo "FreeSpace: " & objItem.FreeSpace
'Wscript.Echo "Size: " & objItem.Size
Wscript.Echo "FreeSpace is : " & Int(Freespace / 1073741824) & " GB"
end if
Cheers!
--
Dee
Post by Richard Mueller [MVP]Post by DeeI want to check multiple objects, but not sure how to add them to the vb
script code
if objItem.Name = "C:" then
I want to check C drive and D drive for space and the above line works ok,
however I want to also check the D drive, but need to know how to add that to
the same line, any thoughts?
In general, conditions can be combined in If/Then statements using "And",
If (objItem.Name = "C:") Or (objItem.Name = "D:") Then
' Statements that run only if name is "C:" or "D:"...
End If
As noted, we may need to see more of your code, or understand what you are
trying to do. It might make sense to check space on C: and D: separately.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--