NOVOTS KMS 词汇表 Glossary    联系我们 Contact Us
查询 Search  
   
按类别浏览 Browse by Category
NOVOTS KMS .: 工作心得 .: 检测本机硬盘信息VBS

检测本机硬盘信息VBS

' *****************************************************************************
' TEST SCRIPT - disks.vbs
' *****************************************************************************
' 作用: 读取本机硬盘信息
' 作者: hank
' 日期: 18:12 2009-2-10
' Copyright (c) hnjhn.com 微软技术联盟
' *****************************************************************************

Option Explicit
Dim d, wmi, disks, logicalDiskSet, count, partitions

Set wmi=GetObject("winmgmts:\\")
Set disks=wmi.InstancesOf("win32_diskdrive")
Set logicalDiskSet = wmi.InstancesOf("Win32_LogicalDisk")

For Each d In disks
count = FormatSize(d.Size)
partitions = d.Partitions
Next

Dim msg : msg = Chr(13) & "本机硬盘信息: " & Chr(13) & Chr(13) & "--------------------------------" & Chr(13) & Chr(13) & "- 总容量: " & count & Chr(13) & Chr(13) & "- 分区数: " & partitions & Chr(13) & Chr(13)

Sub Main()
MsgBox msg, 0, "硬盘总容量"
GetLogicalDisk()
End Sub

Function FormatSize(size)
Dim s : s = ""
If size>1024 Then
size=(size/1024)
s = FormatNumber(size, 1) & " KB"
End If
If size>1024 Then
size=(size/1024)
s = FormatNumber(size, 1) & " MB"
End If
If size>1024 Then
size=(size/1024)
s = FormatNumber(size, 1) & " GB"
End If
FormatSize = s
End Function

Sub GetLogicalDisk()
Dim ld, str : str = Chr(13) & "硬盘分区容量: " & Chr(13) & Chr(13)
str = str & "--------------------------------" & Chr(13) & Chr(13)
For Each ld In logicalDiskSet
str = str & "- " & ld.Name & " " & FormatSize(ld.Size) & Chr(32) & Chr(32) & Chr(32) & Chr(13) & Chr(13)
Next
MsgBox str, 0, "显示硬盘分区"
End Sub

Call Main()


这篇文章对你多有用?

相关文章

article 每次开机启动都CHKDSK检查扫描硬盘D盘
每次系统启动都检查D盘,但是每次检查都没有错误,...

(No rating)  9-21-2013    Views: 1265   
article WINXP每次开机启动都检查扫描硬盘D盘的解决办法
启动命令行操作界面:开始>运行>CMD执行:C:...

(No rating)  1-6-2013    Views: 695   

用户评语

添加评语
当前还没有评语.


.: .: .: .: .:
[ 登陆 ]
北京护航科技有限公司 2006

Novots Technologies Limited