To: lxmxn
此方法成功,例如:
@echo off&Setlocal EnableDelayedExpansion
echo This program is running...
for /f "delims=" %%a in ('FINDSTR .* %0') do (
set /a a+=1
if !a! geq 9 if !a! leq 80 >>hta1.hta echo/%%a
)
exit
::::::::::::::::::::: Hta1 :::::::::::::::::::
<html>
<head>
<title>磁盘空间查看器</title>
<script language="vbscript">
window.resizeTo 473, 300
window.moveTo(screen.width-500)/2,(screen.height-243)/2
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>" & DeviceID & "</td>"
strHTML = strHTML & "<td width=110px align=center><font color=#DB2C00>" & FormatNumber(intTotalSpace,1,-1,-1,0) & "</td>"
strHTML = strHTML & "<td width=110px align=center><font color=#DB2C00>" & FormatNumber(infFuLin,1,-1,-1,0) & "</td>"
strHTML = strHTML & "<td width=110px align=center><font color=#DB2C00>" & FormatNumber(intFreeSpace,1,-1,-1,0) & "</td>"
strHTML = strHTML & "<td width=110px align=center><font color=#FF8000>" & FormatPercent(intFreeSpace/intTotalSpace) & "</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
</script>
</head>
<body>
<br>
<font size="2">磁盘分区的使用情况(单位:<font color="#FF0000">GB</font>)</font></font>
<font size="2"><a style="text-decoration: none" href="http://www.cn-dos.net/forum/"> 中国DOS联盟论坛</a> <a style="text-decoration: none" href=" "> </a></font>
</font>
<br>
<body scroll="no">
<body bgcolor="#d0d0d0">
<hta:application contextmenu="no" icon=hdd.ico>
<span id = "DataArea"></span>
</span>
<span style="color:darkblue" id="footer"></span>
</body>
</html>
::::::::::::::::::::: VBS1 :::::::::::::::::::
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'wscript.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
用 geq 9 取大于等于9行,用 leq 80 取小于等于80行(?), 事实上 </html> 是位于第84行,何解呢?
[ Last edited by axi on 2007-4-5 at 08:01 AM ]