Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.get("Win32_LogicalDisk.DeviceID='d:'")
s = objLogicaldisk.Size/(1024*1024*1024)
s = round(s,2) '全部磁盘容量
m = objLogicalDisk.FreeSpace/(1024*1024*1024)
m = round(m,2) '剩余磁盘空间
a = m/s
a = round(a,2)
w = (FormatPercent(a,2)) '磁盘剩余空间百分比
Set fso = CreateObject("Scripting.FileSystemObject")
pd1=fso.FileExists ("d:\1.txt") '创建d:\1.txt文档
set n=fso.opentextfile("d:\1.txt",8,1) '执行打开d:\1.txt文档
n.writeline now&"删除前可用大小"&w '计算删除前磁盘剩余空间百分比并写入到d:\1.txt中
n.close
Do Until a > 0.1 '执行剩余空间百分比判定
Set shell = WScript.CreateObject("WScript.shell")
shell.Run"d:\1.bat",0
Set objLogicalDisk = objWMIService.get("Win32_LogicalDisk.DeviceID='d:'") '删除文件后再次进行磁盘空间计算
s = objLogicaldisk.Size/(1024*1024*1024)
s = round(s,2)
m = objLogicalDisk.FreeSpace/(1024*1024*1024)
m = round(m,2)
a = m/s
a = round(a,2)
Loop
w = (FormatPercent(a,2)) '执行删除文件后计算剩余空间
set n=fso.opentextfile("d:\1.txt",8,1)
n.writeline now&"删除后可用大小"&w
n.writeline "请注意,当E盘容量小于10%时系统将自动删除保存最久的录音文件!"
n.close
call mail()
fso.DeleteFile file,1 '执行删除d:\1.bat
fso.DeleteFile ("d:\1.txt") '执行删除d:\1.txt
按常理说当D盘可用容量小于10%才执行d:\1.bat脚本的 但是现在一运行就直接执行了1.bat作者: batman 时间: 2012-3-29 14:32