FSO/Drives
'==========================================================================
' NAME: FSO_Drives_List.vbs
' AUTHOR: Neal Walters
' DATE : 3/26/2005
' http://VBScript-Training.com
'==========================================================================
WScript.Echo ShowDriveList
Function ShowDriveList
Dim fso, d, dc, s, n
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.Drives.Item("D:")
n = ""
s = s & d.DriveLetter & " - "
If d.DriveType = Remote Then
n = d.ShareName
ElseIf d.IsReady Then
n = d.VolumeName
End If
s = s & n & VbCrLf
ShowDriveList = s
End Function
'==========================================================================
' NAME: FSO_Drives_List.vbs
' AUTHOR: Neal Walters
' DATE : 3/26/2005
' http://VBScript-Training.com
'==========================================================================
WScript.Echo ShowDriveList
Function ShowDriveList
Dim fso, d, dc, s, n
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
numDrives = dc.Count
WScript.Echo "There are " & numDrives & " on this computer."
For Each d In dc
n = ""
s = s & d.DriveLetter & " - "
If d.DriveType = Remote Then
n = d.ShareName
Elseif d.IsReady Then
n = d.VolumeName & " space available = " & FormatNumber(d.FreeSpace / 1024 / 1024,0) & "MB"
End If
s = s & n & VbCrLf
Next
ShowDriveList = s
End Function
'==========================================================================
' NAME: FSO_Drives_Types.vbs
' AUTHOR: Neal Walters
' DATE : 3/26/2005
' http://VBScript-Training.com
'==========================================================================
Option Explicit
Dim driveTypeCDROM, driveTypeFixed, driveTypeRemovable
driveTypeCDROM = 4
driveTypeFixed = 2
driveTypeRemovable = 1
WScript.Echo ShowDriveList
Function ShowDriveList
Dim fso, d, dc, s, n, drvType, numDrives, remote
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
numDrives = dc.Count
WScript.Echo "There are " & numDrives & " on this computer."
For Each d In dc
n = ""
s = s & d.DriveLetter & " - "
If d.DriveType = Remote Then
n = d.ShareName
Elseif d.IsReady Then
n = d.VolumeName & " space available = " & FormatNumber(d.FreeSpace / 1024 / 1024,0) & "MB"
End If
Select Case d.DriveType
Case driveTypeCDROM
drvType = driveTypeCDROM
Case driveTypeFixed
drvType = "Fixed"
Case driveTypeRemovable
drvType = "Removeable"
Case Else
drvType = d.DriveType
End Select
s = s & " type=" & drvType & " "
s = s & n & VbCrLf
Next
ShowDriveList = s
End Function
|