您的位置:首页 > 职场人生

获取指定盘符信息

2008-11-17 12:25 197 查看
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'获取指定盘符信息: '
'版权所有:坏男孩 '
'MSN:[email]hahazhu0634@live.cn[/email]
'QQ:383088680 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
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 FSO=CreateObject("Scripting.FileSystemObject")
set Drive=fso.GetDrive(fso.GetDriveName(DrviePath))
'显示Drive所有属性
if(Drive.VolumeName)="" then
VolumeName="系统默认"
else
VolumeName=Drive.VolumeName
end if
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 盘符 休闲