bat代码:每分钟获取一次电脑所有硬盘的剩余容量并将数据存储在文档或者Excel里?

以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI

/*&cls&echo off

rem 监控磁盘分区的容量大小变化

set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4

title %#% +%$%%$%/%@% %z%

set sleep=60

:loop

cls&echo;%date% %time%

type "%~f0"|cscript -nologo -e:jscript "%~f0">"%tmp%\v.v"

cscript -nologo -e:vbscript "%tmp%\v.v"

echo;%#% +%$%%$%/%@% %z%

timeout /t %sleep% /nobreak

goto loop

pause

exit

*/

var text=WSH.StdIn.ReadAll();

var m=text.match(/\/\*\r\n([\s\S]+)\*\/\s*$/);

WSH.echo(m[1]);

/*

On Error Resume Next

Set fso=CreateObject("Scripting.Filesystemobject")

Set wmi=GetObject("winmgmts:\\.\root\cimv2")

Set query=wmi.ExecQuery(StrReverse("2=epyTevirD ro 3=epyTevirD erehW ksiDlacigoL_23niW morf * tceleS"))

For each item in query

usedsize=item.Size - item.FreeSpace

usedspace=FormatSize(usedsize) & "(" & PercenTage(usedsize/item.Size) & ")"

freespace=FormatSize(item.FreeSpace) & "(" & PercenTage(item.FreeSpace/item.Size) & ")"

WSH.StdErr.WriteLine item.Caption & Chr(9) & FormatSize(item.Size) & Chr(9) & usedspace & Chr(9) & freespace

Next

Function FormatSize(byVal t)

If 1*t >= 1024^4 Then

FormatSize=FormatNumber(t/(1024^4), 2, true) & "TB"

ElseIf 1*t >= 1024^3 Then

FormatSize=FormatNumber(t/(1024^3), 2, true) & "GB"

ElseIf 1*t >= 1024^2 Then

FormatSize=FormatNumber(t/(1024^2), 2, true) & "MB"

ElseIf 1*t >= 1024 Then

FormatSize=FormatNumber(t/1024, 2, true) & "KB"

Else

FormatSize=t & "B"

End If

End Function

Function PercenTage(byVal t)

PercenTage=FormatNumber(100*t, 2, true) & "%"

End Function

*/