set fso = CreateObject("Scripting.FileSystemObject") '创建fso对象 set colDrives = fso.Drives '获取驱动器号列表 ForEach disk in colDrives '遍历驱动器号 WSH.Echo(disk) Next
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Set fso = CreateObject("Scripting.FileSystemObject") Set colDrives = fso.Drives ForEach drive in colDrives If drive.IsReady = TrueThen WSH.Echo("盘符: " & drive.DriveLetter) WSH.Echo("磁盘序列号:" & drive.SerialNumber) WSH.Echo("磁盘类型:" & drive.DriveType) WSH.Echo("文件系统的类型:" & drive.filesystem) WSH.Echo("磁盘名称: " & drive.VolumeName) WSH.Echo("总容量:" &drive.TotalSize) WSH.Echo("剩余容量: " & drive.FreeSpace) WSH.Echo("可选容量:" & drive.AvailableSpace) Else WSH.Echo("盘符: " & drive.DriveLetter) EndIf Next