中国DOS联盟论坛

中国DOS联盟

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

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

游客:  注册 | 登录 | 命令行 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 用VBS做磁盘空间查看脚本hta文本文件
作者:
标题: 用VBS做磁盘空间查看脚本hta文本文件 上一主题 | 下一主题
Nickey
初级用户




积分 132
发帖 59
注册 2007-8-23
来自 GuangZhou
状态 离线
『楼 主』:  用VBS做磁盘空间查看脚本hta文本文件

这个贴不知该在哪里发 既然有位仁兄已经发了一个代码编辑器的hta文件
我也将存放在网页里面多时的文件与大家分享
*注以下代码<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="JavaScript"><!--显示时间-->
function showClock() {}
function hideClock() {}
var timerRunning = false
function stopClock() {if(timerRunning) clearTimeout(timerID)}
function showTime() {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hours = now.getHours();
var mins = now.getMinutes();
var secs = now.getSeconds();
today=new Date();
if(today.getDay()==0) week="星期日"
if(today.getDay()==1) week="星期一"
if(today.getDay()==2) week="星期二"
if(today.getDay()==3) week="星期三"
if(today.getDay()==4) week="星期四"
if(today.getDay()==5) week="星期五"
if(today.getDay()==6) week="星期六"
var timeVal = year + "-" + month + "-" + date + " ";
timeVal += ((hours < 10) ? "0" : "") + hours;
timeVal += ((mins < 10) ? ":0" : ":") + mins;
timeVal += ((secs < 10) ? ":0" : ":") + secs;
timeVal += "(" + week + ")";
lastVal = "<" + document.lastModified + ">";
document.Show.CLK1.value=timeVal; timerID=setTimeout("showTime()", 1000); timerRunning = true;
document.Show.CLK2.value=lastVal;
}
</Script>
<script language="vbscript"><!--分区情况列表-->
window.resizeTo 500, 410
ileft = (window.screen.width-500)/2
itop = (window.screen.height-500)/2
window.moveTo ileft,itop

Sub Window_onLoad
GetDiskSpace
End Sub
Sub GetDiskSpace
Const HARD_DISK = 3
Const GB = 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 border='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/GB
intTotalSpace = objDisk.Size/GB
pctFreeSpace = intFreeSpace/GB / intTotalSpace/GB
infFuLin = intTotalSpace-intFreeSpace
DeviceID = objDisk.DeviceID
strHTML = strHTML + "<tr>"
strHTML = strHTML + "<td width=110px align=center><font color=000000>" + DeviceID + "</font></td>"
strHTML = strHTML + "<td width=110px align=center><font color=008040>" + FormatNumber(intTotalSpace,1,-1,-1,0) + "</font></td>"
strHTML = strHTML + "<td width=110px align=center><font color=ff0000>" + FormatNumber(infFuLin,1,-1,-1,0) + "</font></td>"
strHTML = strHTML + "<td width=110px align=center><font color=ba75ff>" + FormatNumber(intFreeSpace,1,-1,-1,0) + "</font></td>"
strHTML = strHTML + "<td width=110px align=center><font color=0080c0>" + FormatPercent(intFreeSpace/intTotalSpace) + "</font></td>"
Next
strHTML = strHTML + "</table>"
DataArea.InnerHTML = strHTML
End Sub
Sub setx(t)
dim obj : set obj = window.event.srcElement
if t = "" Then
obj.style.color = "gray"
obj.style.cursor = "default"
Else
obj.style.color = "darkblue"
obj.style.cursor = "hand"
End if
footer.innerHTML = t
end Sub
Const StrCont = "<font size=2 COLOR='8000ff'>版本最后更新日期</font>"
const StrMail = "<font size=2 COLOR='8000ff'>kanlis25@hotmail.com</font>"
const Connect = "<font size=2 COLOR='8000ff'>http://hi.814e.com/kanlis</font>"
</script>
</head>
<body onmouseover=showTime() bgcolor="acd6ff">
<p ALIGN="CENTER">
<a href="http://hi.814e.com/kanlis/index.html">
<span onmouseover=setx(Connect) onmouseout=setx('')>
<font SIZE="4" color="e87400">【:::衰仔樂園:::】</font>
</span>
</a>
</p>
<font size="2">查看各分区磁盘使用情况(<font color="red">/GB</font>)</font>&nbsp;
<span id="DataArea"></span>
<form name="Show" onsubmit=0>
<font style="color:gray" SIZE="2">
<span onmouseover=setx(StrMail) onmouseout=setx('')>
<INPUT SIZE="30" style="BACKGROUND-COLOR:#d6acff" ID="CLK1">
</span>
<span onmouseover=setx(StrCont) onmouseout=setx('')>
<INPUT SIZE="30" style="BACKGROUND-COLOR:#d6acff" ID="CLK2">
</span>
</font>
</form>
<span style="color:darkblue" id="footer"></span>
</body>
</html>


Last edited by Nickey on 2007-10-8 at 01:32 PM ]

附件 1: 硬盘空间查看脚本.zip (2007-10-8 13:32, 1.97 KiB,下载次数: 23)
2007-10-7 20:58
查看资料  发送邮件  访问主页  发短消息  网志  OICQ (375600651)  编辑帖子  回复  引用回复
wudixin96
银牌会员





积分 1928
发帖 931
注册 2007-1-6
状态 离线
『第 2 楼』:  

能不能规范点??用code包起来??

2007-10-7 21:05
查看资料  发短消息  网志   编辑帖子  回复  引用回复
tireless
银牌会员





积分 2025
发帖 1122
注册 2007-9-5
状态 离线
『第 3 楼』:  

hta脚本挺好玩的 有界面

2007-10-8 01:36
查看资料  发短消息  网志   编辑帖子  回复  引用回复
wert123
中级用户





积分 301
发帖 135
注册 2007-5-15
状态 离线
『第 4 楼』:  

怎么不能查移动盘,怎么改下能查所有类型的盘?

2007-10-9 00:53
查看资料  发短消息  网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: