<html>
<head>
<title>磁盘空间查看脚本</title>
<hta:application
applicationname=磁盘空间查看脚
border=dialog
borderstyle=normal
caption=yes
contextmenu=no
maximizebutton=no
minimizebutton=yes
navigable=no
scroll=yes
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, 420
ileft=(window.screen.width-500)/2
itop=(window.screen.height-420)/2
window.moveto ileft,itop
sub window_onload
getdiskspace
end sub
sub getdiskspace
const hard_disk = 3
const size = 1048576
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='1'>
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,2,-1,-1,0) & </td>
strhtml = strhtml & <td width=110px align=right><font color=#db2c00> & formatnumber(inffulin,2,-1,-1,0) & </td>
strhtml = strhtml & <td width=110px align=right><font color=#008080> & formatnumber(intfreespace,2,-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>
<body>
<!-- html goes here -->
<table align=center width=95%><font color=#c63358><b>磁盘空间查看脚本</b></font><br>
<font size=2>显示各磁盘分区使用情况(<font color=#ff0000>/mb</font>)</font></font></table>
<body bgcolor=#99ccff>
<span id = dataarea></span>
</body>
</html>
保存为hta文件.