vbs判断磁盘类型和检测硬盘剩余空间的实现代码
核心代码:
FunctionShowDriveType(drvpath)
Dimfso,d,t
Setfso=CreateObject("Scripting.FileSystemObject")
Setd=fso.GetDrive(fso.GetDriveName(drvpath))
SelectCased.DriveType
Case0t="Unknown"
Case1t="Removable"'移动硬盘
Case2t="Fixed"'硬盘
Case3t="Network"'网络硬盘
Case4t="CD-ROM"
Case5t="RAMDisk"'RAM
EndSelect
ShowDriveType="Drive"&d.DriveLetter&":-"&t
EndFunction
FunctionShowFreeSpace(drvPath)
Dimfso,d,s
Setfso=CreateObject("Scripting.FileSystemObject")
Setd=fso.GetDrive(fso.GetDriveName(drvPath))'d为F:
s="Drive"&UCase(drvPath)&"-"
s=s&d.VolumeName&""
s=s&"FreeSpace:"&FormatNumber(d.FreeSpace/1024,0)
s=s&"KBytes"
ShowFreeSpace=s
EndFunction
Dimmessage
message=ShowDriveType("F:\Programming\Applications")
MsgBoxmessage
message=ShowFreeSpace("F:\Programming\Applications")
MsgBoxmessage