ObjectOrientedIntro.vbs
'==========================================================================
' NAME: ObjectOrientedIntro.vbs
' AUTHOR: Neal Walters , Amerisoft Inc
' http://VBScript-Training.com
' DATE : 3/26/2005
'==========================================================================
Option Explicit
Dim myfilename
myfilename = "C:\test\abc.txt"
Call ShowDriveInfo(myfilename)
myfilename = "D:\test\abc.txt"
Call ShowDriveInfo(myfilename)
Sub ShowDriveInfo(drvPath)
Dim fso, drv, s, drvname
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
drvname = fso.GetDriveName(drvPath)
Set drv = fso.GetDrive(drvname)
If drv.IsReady Then
s = "Drive " & UCase(drvName) & " - "
s = s & drv.VolumeName & VbCrLf
s = s & "Total Space: " & FormatNumber(drv.TotalSize / 1024, 0)
s = s & " Kb" & VbCrLf
s = s & "Free Space: " & FormatNumber(drv.FreeSpace / 1024, 0)
s = s & " Kb" & VbCrLf
s = s & "Available Space: " & FormatNumber(drv.AvailableSpace / 1024, 0)
s = s & " Kb" & VbCrLf
s = s & "Serial Number: " & drv.SerialNumber
s = s & VbCrLf
WScript.Echo s
Else
WScript.Echo "Drive " & drvname & " is not ready "
End If
End Sub
|