Return to Snippet

Revision: 59822
at October 3, 2012 17:00 by saqibmj


Initial Code
'-----------------------------------------------------------------------------------------------------------------------------------
' Function    : DiskUse(string)
' Description : This Function gets information about the Logical Drives present in a System
' Parameter   : Computer IP ['.' for local computer]
' Return      : strOut (String in [C: 10 GB free of 100 GB] [D: 10 GB free of 100 GB]) 
' Created By  : Saqib Mujtaba
' Created On  : 27-Sept-2012
'-----------------------------------------------------------------------------------------------------------------------------------
Function DiskUse(strComputer)
On Error Resume Next
	Dim objDiskUse,objDisk,strOut
	strOut=""
	Err.Clear
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err=0 Then
	Set objDiskUse = objWMIService.ExecQuery("Select * from Win32_LogicalDisk")
	For Each objDisk in objDiskUse
		If objDisk.DriveType = 3 Then
			strOut = strOut & "[" & objDisk.DeviceID & " " & Round(objDisk.FreeSpace/1073741824,2) & " GB free of " & Round(objDisk.Size /1073741824,2) & " GB] " '& vbNewFile  
		End If
	Next 

	DiskUse = strOut
Else
		DiskUse ="WMI Connection Failed,WMI Connection Failed"
	End If 
	Set objDiskUse = Nothing 
	Set objWMIService = Nothing 
End Function

Initial URL

                                

Initial Description
Function to get the Logical Disk Drive Memory Information.

Initial Title
Function to get the Logical Disk Drive Memory Information.

Initial Tags

                                

Initial Language
Visual Basic