电脑上有多个磁盘在diskinfo的log文件中用批处理获取C盘 Power On Hours 5273 小时 Power On Count 837 次 Host Writes 9343 GB 这些信息
您可以使用批处理脚本来获取磁盘信息并提取所需的信息。以下是一个示例脚本:
@echo off
set "drive=C"
for /f "tokens=1,2" %%a in ('diskinfo.exe --json') do (
if "%%a"=="Drive" (
set "current_drive=%%b"
)
if "%%a"=="Power" (
if "%%b"=="On" (
set "power_on_hours="
set "power_on_count="
set "host_writes="
)
if "%%b"=="On" (
set "power_on_hours_found=true"
)
if "%%b"=="Count" (
set "power_on_count_found=true"
)
if "%%b"=="Writes" (
set "host_writes_found=true"
)
)
if defined power_on_hours_found (
if "%%a"=="Hours" (
set "power_on_hours=%%b"
set "power_on_hours_found="
)
)
if defined power_on_count_found (
if "%%a"=="Count" (
set "power_on_count=%%b"
set "power_on_count_found="
)
)
if defined host_writes_found (
if "%%a"=="Writes" (
set "host_writes=%%b"
set "host_writes_found="
)
)
if defined power_on_hours (
if defined power_on_count (
if defined host_writes (
if /i "!current_drive!"=="%drive%" (
echo Power On Hours : !power_on_hours! 小时
echo Power On Count : !power_on_count! 次
echo Host Writes : !host_writes! GB
exit /b
)
)
)
)
)
要使用此脚本,请确保将diskinfo.exe工具的路径添加到系统的环境变量中,或者将该工具与脚本放在同一个文件夹中。
将脚本中的drive变量设置为所需的磁盘驱动器字母(在这种情况下为C盘)。运行脚本后,它将在命令提示符窗口中显示所需的信息。
原文地址: http://www.cveoy.top/t/topic/i6x8 著作权归作者所有。请勿转载和采集!