天天看点

获取指定盘符信息

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,如需转载请自行联系原作者

继续阅读