set FSO=CreateObject("Scripting.FileSystemObject")
set dc=FSO.Drives
Dim dName
dName=""
For Each d in dc
dName=dName&d.DriveLetter&"盤 "
'Wscript.echo dName
Next
Wscript.Echo "溫馨提醒:"+vbCRLF+vbTab+"您的電腦磁盤僅有"&dName+vbCRLF+"如果您輸入的盤符不在這個範圍内,或者CD-ROM無法加載,"+vbcrlf+"将不會有任何磁盤資訊顯示!"
set dc=nothing
Set fso=nothing
ON ERROR RESUME NEXT
Dim DrviePath
DrviePath=InputBox("請輸入您要檢查的磁盤:(格式:盤符:,盤符:\指定路徑)")
if Trim(DrviePath)<>"" then
Wscript.Echo GetDrive(DrviePath)
Function GetDrive(DrviePath)
Dim fso
Dim s
Dim tp
Dim dc
s=""
if instr(DrivePath,":")= 0 then '當用戶端輸入c等,那麼需要将其合并成c:
DrviePath=DrviePath&":"
end if
set Drive=fso.GetDrive(fso.GetDriveName(DrviePath))
'顯示Drive所有屬性
if(Drive.VolumeName)="" then
VolumeName="系統預設"
else
VolumeName=Drive.VolumeName
s="驅動盤符:"&Drive.DriveLetter&"盤"
s=s+vbCRLF+"檔案系統類型:"&Drive.FileSystem
s=s+vbCRLF+Drive.DriveLetter&"磁盤總空間:"&FormatNumber(Drive.TotalSize/(1024*1024*1024))&"GB"
s=s+vbCRLF+Drive.DriveLetter&"盤剩餘空間:"&FormatNumber(Drive.AvailableSpace/(1024*1024*1024))&"GB"
s=s+vbCRLF+Drive.DriveLetter&"盤卷标:"&VolumeName
Tnum=Drive.DriveType'驅動類型
if(Tnum=0) then
tp = "磁盤不清楚"
elseif(Tnum=2) then
tp="邏輯磁盤"
else
tp="其他磁盤"
end if
s=s+vbCRLF+"驅動器類型:"&tp
GetDrive=s
set Drive=nothing
set fso=nothing
End Function
Else
Wscript.echo "您放棄了磁盤資訊顯示功能!"
End if
本文轉自hahazhu0634 51CTO部落格,原文連結:http://blog.51cto.com/5ydycm/113255,如需轉載請自行聯系原作者