标题: 求所有分区已用/未用空间的精确值(hta脚本)
[打印本页]
作者: zh159
时间: 2007-3-12 06:07
标题: 求所有分区已用/未用空间的精确值(hta脚本)
今天从网上淘到的,原是GB,改为MB,并稍加修改了界面
hta脚本(扩展名为hta)
<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>
附件为原作者的代码文件
[
Last edited by zh159 on 2007-3-12 at 10:46 AM ]
附件
1: 自己修改的磁盘空间查看脚本界面.gif (2007-3-12 06:07, 18.58 K, 下载附件所需积分 1点
,下载次数: 2)
附件
2: 原磁盘空间查看脚本.rar (2007-3-12 06:07, 1.54 K, 下载附件所需积分 1点
,下载次数: 43)
作者: ccwan
时间: 2007-3-12 07:10
沙发!
这是个好东西,谢谢分享。
作者: ccwan
时间: 2007-3-12 07:14
这是显示GB的。
附件
1: snap.gif (2007-3-12 07:14, 38.03 K, 下载附件所需积分 1点
,下载次数: 2)
作者: zhoushijay
时间: 2007-3-12 07:20
不用vb 用DOS命令+html能做出这样的效果来吗?
作者: xycoordinate
时间: 2007-3-12 08:06
看看
作者: lxmxn
时间: 2007-3-12 09:51
弄一个简单的WMIC的吧:(适用Windows xp 以上系统)
@echo off
wmic /output:a.html logicaldisk where "DriveType=3" get DeviceID,Size,FreeSpace,Description,FileSystem /format:htable.xsl
start a.html
[
Last edited by lxmxn on 2007-3-11 at 08:53 PM ]
作者: anqing
时间: 2007-3-12 12:18
a.html在哪里呀?
作者: yishanju
时间: 2007-3-13 03:26
Quote: |
Originally posted by lxmxn at 2007-3-12 09:51:
弄一个简单的WMIC的吧:(适用Windows xp 以上系统)
[code]
@echo off
wmic /output:a.html logicaldisk where "DriveType=3" get DeviceID,Size,FreeSp ... |
|
:)应该在system32 里面吧
作者: lxmxn
时间: 2007-3-13 03:30
Quote: |
Originally posted by anqing at 2007-3-11 23:18:
a.html在哪里呀? |
|
在批处理文件所在的目录中。
作者: axi
时间: 2007-3-13 04:03
我觉得原创的显示GB方式简洁好用。lxmxn 的方法更简单,真佩服你的脚本技术,能否把此信息创建到当前下的一个文本中呢?
作者: lxmxn
时间: 2007-3-13 04:11
Quote: |
Originally posted by axi at 2007-3-12 15:03:
我觉得原创的显示GB方式简洁好用。lxmxn 的方法更简单,真佩服你的脚本技术,能否把此信息创建到当前下的一个文本中呢? |
|
方法有多种:
将所生成的信息定向到a.txt:
1、
wmic /output:a.txt logicaldisk where "DriveType=3" get DeviceID,Size,FreeSpace,Description,FileSystem
2、
wmic logicaldisk where "DriveType=3" get DeviceID,Size,FreeSpace,Description,FileSystem>a.txt
作者: axi
时间: 2007-3-13 05:51
能否使 ”磁盘空间查看脚本“ 的窗体高度根据内容自动调整。
作者: hapeacock
时间: 2007-8-22 20:59
支持多硬盘不||??
作者: Nickey
时间: 2007-8-25 14:28
29729.63MB 很不直观
还是17.1GB 直观些
毕竟现在的硬盘动辄数百GB级了
作者: wxhh12
时间: 2007-11-28 14:26
thanks
作者: zh159
时间: 2007-11-28 15:40
Quote: |
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>
作者: justinzang
时间: 2008-5-28 11:36
Quote: |
Originally posted by yishanju at 2007-3-13 03:26 AM:
:)应该在system32 里面吧 |
|
我怎么在system32中没有找到啊?这个脚本能在指定的位置生成一个html页面吗?
作者: justinzang
时间: 2008-5-28 17:11
顶一下,斑竹帮忙给看看?