中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-07-31 21:20
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 求所有分区已用/未用空间的精确值(hta脚本) 查看 2,519 回复 17
16 发表于 2007-11-28 15:40 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
积分 3,687
发帖 1,467
注册 2005-08-08 12:00
20年会员
UID 44210
状态 离线
Originally posted by Nickey at 2007-8-25 14:28:
29729.63MB 很不直观
还是17.1GB 直观些
毕竟现在的硬盘动辄数百GB级了


GB单位的,精确到0.001GB
<html>
<head>

<title>磁盘空间查看脚本</title>

<hta:application
applicationname="磁盘空间查看脚"
border="thin"
borderstyle=""
caption="yes"
contextmenu="no"
maximizebutton="no"
minimizebutton="yes"
navigable="yes"
scroll="no"
innerborder="no"
selection="no"
showintaskbar="yes"
singleinstance="yes"
sysmenu="yes"
version="1.0"
windowstate="normal"
>

<script language="vbscript">
<!-- Insert code, subroutines, and functions here -->
window.resizeTo 500, 300
ileft=(window.screen.width-500)/2
itop=(window.screen.height-300)/2
window.moveTo ileft,itop

Sub Window_onLoad
GetDiskSpace
End Sub

Sub GetDiskSpace
Const HARD_DISK = 3
Const Size = 1073741824

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")
strHTML = "<table align=center width=95% borderColor=#698cc2 border='1' cellSpacing='0' cellpadding='0'>"
strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td width=110px align=center><font size=2><b>" & "分区" & "</b></td>"
strHTML = strHTML & "<td width=110px align=center><font size=2><b>" & "容量" & "</b></td>"
strHTML = strHTML & "<td width=110px align=center><font size=2><b>" & "已用" & "</b></td>"
strHTML = strHTML & "<td width=110px align=center><font size=2><b>" & "未用" & "</b></td>"
strHTML = strHTML & "<td width=110px align=center><font size=2><b>" & "空闲" & "</b></td>"


For Each objDisk In colDisks
intFreeSpace = objDisk.FreeSpace/Size
intTotalSpace = objDisk.Size/Size
pctFreeSpace = intFreeSpace/Size/ intTotalSpace/Size
infFuLin = intTotalSpace-intFreeSpace
DeviceID = objDisk.DeviceID
strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td width=110px align=center>" & DeviceID & "</td>"
strHTML = strHTML & "<td width=110px align=right>" & FormatNumber(intTotalSpace,3,-1,-1,0) & "</td>"
strHTML = strHTML & "<td width=110px align=right><font color=#DB2C00>" & FormatNumber(infFuLin,3,-1,-1,0) & "</td>"
strHTML = strHTML & "<td width=110px align=right><font color=#008080>" & FormatNumber(intFreeSpace,3,-1,-1,0) & "</td>"
strHTML = strHTML & "<td width=110px align=right>" & FormatPercent(intFreeSpace/intTotalSpace) & "</td>"

Next
strHTML = strHTML & "</table>"
DataArea.InnerHTML = strHTML
End Sub

</script>
</head>

<!-- HTML goes here -->
<body bgcolor="#99CCFF">
<table align=center width=95%><font color="#C63358"><b>磁盘空间查看脚本</b></font><br>
<font size="2">显示各磁盘分区使用情况(<font color="#FF0000">/GB</font>)</font></font></table>
<span id = "DataArea"></span>
</body>
</html>
17 发表于 2008-05-28 11:36 ·  中国 山东 青岛 联通
新手上路
积分 9
发帖 5
注册 2008-03-13 16:50
18年会员
UID 112858
性别 男
状态 离线
Originally posted by yishanju at 2007-3-13 03:26 AM:


:)应该在system32 里面吧


我怎么在system32中没有找到啊?这个脚本能在指定的位置生成一个html页面吗?
18 发表于 2008-05-28 17:11 ·  中国 山东 青岛 联通
新手上路
积分 9
发帖 5
注册 2008-03-13 16:50
18年会员
UID 112858
性别 男
状态 离线
顶一下,斑竹帮忙给看看?
论坛跳转: