脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - VBS - vbs判断磁盘类型和检测硬盘剩余空间的实现代码

vbs判断磁盘类型和检测硬盘剩余空间的实现代码

2020-08-16 14:24VBS代码网 VBS

这篇文章主要介绍了vbs判断磁盘类型和检测硬盘剩余空间的实现代码,需要的朋友可以参考下

核心代码:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Function ShowDriveType(drvpath)
  Dim fso, d, t
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set d = fso.GetDrive(fso.GetDriveName(drvpath))
  Select Case d.DriveType
   Case 0 t = "Unknown"
   Case 1 t = "Removable"  '移动硬盘
   Case 2 t = "Fixed"    '硬盘
   Case 3 t = "Network"   '网络硬盘
   Case 4 t = "CD-ROM"
   Case 5 t = "RAM Disk"   'RAM
  End Select
  ShowDriveType = "Drive " & d.DriveLetter & ": - " & t
End Function
 
Function ShowFreeSpace(drvPath)
 Dim fso, d, s
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set d = fso.GetDrive(fso.GetDriveName(drvPath))    'd为F:
 s = "Drive " & UCase(drvPath) & " - "
 s = s & d.VolumeName & " "
 s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0)
 s = s & " KBytes"
 ShowFreeSpace = s
End Function
 
Dim message
 
message = ShowDriveType("F:\Programming\Applications")
MsgBox message
message = ShowFreeSpace("F:\Programming\Applications")
MsgBox message

延伸 · 阅读

精彩推荐