|
|
发表于 2019-1-7 21:12:18
|
显示全部楼层
本帖最后由 523066680 于 2019-1-7 21:29 编辑
回复 26# aries215
不懂批处理,按零请高明

我发现我把total 和 free写反了,win7测试勉强OK,不知道有没有其他BUG- @echo off
- SetLocal EnableDelayedExpansion
- :: 常量初始化
- set const=9876543210
- :get_free_size
- for /f "tokens=3" %%i in ('fsutil volume diskfree c:') do (set free=%%i&goto :get_total_size)
- :get_total_size
- for /f "tokens=3" %%i in ('fsutil volume diskfree c: ^|more +1') do (set total=%%i&goto :count)
- :count
- set /a Afoo=%total:~0,-5%, Abar=%total:~-5%
- set /a Bfoo=%free:~0,-5%, Bbar=%free:~-5%
- echo %Afoo% %Abar% %Bfoo% %Bbar%
- set /a foo=Afoo-Bfoo, bar=Abar-Bbar
- if %bar% leq 0 set /a foo-=1, bar=100000-(-bar)
- echo,
- echo %total% %free% 已用空间 %foo%%bar%
- exit /b
复制代码 |
|