[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] [交流]批处理如何通过鲁大师日志提取硬件信息,重复数据太多

本帖最后由 yakeyun 于 2022-7-26 00:07 编辑

鲁大师运行后会在程序安装路径下生成一个日志文件:C:\Program Files (x86)\LuDaShi\Log\ComputerZ_HardwareDll.log
这个里面包含了所有主机里面的硬件信息,但是自己通过下面代码提取后,出现许多重复项,也找不到规律来很好的提取信息。
  1. @echo off & setlocal enabledelayedexpansion
  2. pushd "C:\Program Files (x86)\LuDaShi\log"
  3. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[overviewinfowrapper] CPUName :"') do set CPUName=%%a
  4. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do set MemoryNumber=%%a
  5. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.0"') do set Memory0Name=%%a
  6. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory1Name=%%a
  7. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.2"') do set Memory2Name=%%a
  8. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.3"') do set Memory3Name=%%a
  9. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[gpuprocesser] VideoAdapter"') do set VideoAdapter=%%a
  10. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[motherboardinfowrapper] GetMotherboardInfo:"') do set MotherboardInfo=%%a
  11. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[monitorinfowrapper] find primary monitor"') do set monitor=%%a
  12. for /f "tokens=3* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[disk_client] ModelNumber"') do set Diskinfo=%%a
  13. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] ="') do set Network0=%%a
  14. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] ="') do set Network1=%%a
  15. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] ="') do set Network2=%%a
  16. for /f "tokens=2* delims=@" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[audioinfo] Multimedia(Hi-definition Audio):"') do set audioinfo=%%a
  17. set CPUName
  18. set MemoryNumber
  19. if !MemoryNumber! EQU 1 set Memory0Name
  20. if !MemoryNumber! EQU 2 set Memory0Name & set Memory1Name
  21. if !MemoryNumber! EQU 3 set Memory0Name & set Memory1Name & set Memory2Name
  22. if !MemoryNumber! EQU 4 set Memory0Name & set Memory1Name & set Memory2Name & set Memory3Name
  23. set VideoAdapter
  24. set MotherboardInfo
  25. set monitor
  26. set Diskinfo
  27. set Network0
  28. set Network1
  29. set Network2
  30. set audioinfo
  31. pause
复制代码
日志文件下载地址,数据重新打包了:
https://sanli.lanzoub.com/iLWkp08elamb




--------[ 鲁大师 ]----------------------------------------------------------------------------------

  软件:                 鲁大师 6.1022.3375.630
  时间:                 2022-07-25 20:41:10
  软件:                 http://www.ludashi.com

--------[ 概览 ]----------------------------------------------------------------------------------

  电脑型号               铭瑄 MS-TZZ H610M 台式电脑
  操作系统               Windows 11 专业版 64位(Version 21H2 / DirectX 12)

  处理器                 12th Gen Intel Core i5-12400F 六核
  主板                   铭瑄 MS-TZZ H610M(英特尔 PCH)
  显卡                   NVIDIA GeForce RTX 3050 ( 8 GB / 华硕 )
  内存                   16 GB ( 英睿达 DDR4 3200MHz 8GB / 镁光 DDR4 3200MHz 8GB )
  主硬盘                 技嘉 GP-GSM2NE3256GNTD (256 GB / 固态硬盘)
  显示器                 惠科 HKC2413 GF40 ( 23.6 英寸  )
  声卡                   英特尔 High Definition Audio 控制器
  网卡                   瑞昱 RTL8168/8111/8112 Gigabit Ethernet Controller

--------[ 主板 ]----------------------------------------------------------------------------------

  主板型号               铭瑄 MS-TZZ H610M
  芯片组                 英特尔 PCH
  序列号                 Default string
  BIOS                   安迈  International, LLC. 5.24  /  BIOS程序发布日期: 02/24/2022
  BIOS的大小             16384 KB

  板载设备               Device 1 / 未知 (启用)

--------[ 处理器 ]----------------------------------------------------------------------------------

  处理器                 12th Gen Intel Core i5-12400F 六核
  速度                   4.00 GHz
  处理器数量             核心数:6 / 线程数:12
  核心代号               Alder Lake
  生产工艺               10 nm
  插槽/插座              FCLGA1700
  一级数据缓存           6 x 48 KB, 12-Way, 64 byte lines
  一级代码缓存           6 x 32 KB, 8-Way, 64 byte lines
  二级缓存               6 x 1.25 MB, 10-Way, 64 byte lines
  三级缓存               18 MB, 12-Way, 64 byte lines
  特征                   MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, HTT, EM64T, EIST, Turbo Boost

--------[ 硬盘 ]----------------------------------------------------------------------------------

  产品                   技嘉  GP-GSM2NE3256GNTD (固态硬盘)
  大小                   256 GB
  固件                   EDFM90.0
  接口                   PCI-E 3x4
  数据传输率             4000.00 MB/秒
  特性                   S.M.A.R.T
  硬盘已使用             共 223 次,累计 968 小时

  产品                   酷兽  C5S-EVO 60G (固态硬盘)
  大小                   60 GB
  固件                   C1EC53
  接口                   SATA III
  数据传输率             600 MB/秒
  特性                   S.M.A.R.T,  APM,  48-bit LBA,  NCQ
  硬盘已使用             共 842 次,累计 4273 小时

  产品                   西数  WD5003ABYZ-011FA0
  大小                   500 GB
  固件                   19.01H19
  缓存                   64 MB
  接口                   SATA III
  数据传输率             600.00 MB/秒
  特性                   S.M.A.R.T,  48-bit LBA,  NCQ
  硬盘已使用             共 96 次,累计 409 小时
  转速                   7200 转/分

--------[ 内存 ]----------------------------------------------------------------------------------

  Controller0-ChannelA-DIMM0       英睿达 DDR4 3200MHz 8GB
  制造日期               2021 年 40 周
  型号                   CT8G4DFS632A.C4FE
  序列号                 E62849FB
  厂商                   Crucial
  模块位宽               64 Bits
  模块电压               SSTL 1.2V

  Controller1-ChannelA-DIMM0       镁光 DDR4 3200MHz 8GB
  制造日期               2020 年 27 周
  型号                   4ATF1G64AZ-3G2E1
  序列号                 28F80D36
  厂商                   Micron
  模块位宽               64 Bits
  模块电压               SSTL 1.2V

--------[ 显卡 ]----------------------------------------------------------------------------------

  主显卡                 NVIDIA GeForce RTX 3050
  显存                   8 GB
  频率                   核心: 1552MHz / 显存: 1750MHz
  显卡制造商             华硕
  芯片制造商             Nvidia
  BIOS版本               94.06.37.00.71
  驱动版本               30.0.15.1295
  驱动日期               20220519

--------[ 显示器 ]----------------------------------------------------------------------------------

  产品                   惠科 HKC2413 GF40
  厂商                   惠科
  固件程序日期           2019 年 11 周
  屏幕尺寸               23.6 英寸 (521 毫米 x 297 毫米)
  分辨率                 1920 x 1080 32 位真彩色
  Gamma                  2.20
  电源管理               Active-Off

--------[ 其他设备 ]----------------------------------------------------------------------------------

  网卡                   Realtek PCIe GbE Family Controller #2

  声卡                   英特尔 High Definition Audio 控制器

  声卡                   NVIDIA 标准 VGA 图形适配器 @ NVIDIA High Definition Audio 控制器

@echo off & setlocal enabledelayedexpansion
for /f "delims==" %%a in ('set GetPCVendor_ID[ 2^>nul') do set "%%a="
cd /d "%~dp0"
for /f "tokens=* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "GetPCVendor"') do (
        set "tmp_str=%%a"
        set "tmp_str=!tmp_str:*GetPCVendor=GetPCVendor!
        if not defined GetPCVendor_ID[!tmp_str!] (
                echo %%a
                set "GetPCVendor_ID[!tmp_str!]=True"
        )
)
1

评分人数

TOP

本帖最后由 yakeyun 于 2022-7-25 13:25 编辑

回复 2# hfxiang


可以过滤,不过后面自己修改了下,获取后依然存在重复项。修改后的代码如下:
  1. @echo off & setlocal enabledelayedexpansion
  2. cd /d "%~dp0"
  3. echo.
  4. echo.
  5. for /f  "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[overviewinfowrapper] CPUName :"') do if not defined %%a set "%%a=%%a" & echo CPUName=%%a
  6. echo.
  7. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do echo MemoryNumber=%%a
  8. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.0"') do echo Memory0Name=%%a
  9. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do echo Memory1Name=%%a
  10. echo.
  11. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[gpuprocesser] VideoAdapter"') do if not defined %%a set "%%a=%%a" & echo VideoAdapter=%%a
  12. echo.
  13. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[motherboardinfowrapper] GetMotherboardInfo:"') do if not defined %%a set "%%a=%%a" & echo MotherboardInfo=%%a
  14. echo.
  15. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[monitorinfowrapper] find primary monitor"') do if not defined %%a set "%%a=%%a" & echo monitor=%%a
  16. echo.
  17. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[disk_client] PrimarayDiskModel:"') do if not defined %%a set "%%a=%%a" & echo Diskinfo=%%a
  18. echo.
  19. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] ="') do if not defined %%a set "%%a=%%a" & echo Network0=%%a
  20. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] ="') do if not defined %%a set "%%a=%%a" & echo Network1=%%a
  21. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] ="') do if not defined %%a set "%%a=%%a" & echo Network2=%%a
  22. echo.
  23. for /f "tokens=2* delims=@" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[audioinfo] Multimedia(Hi-definition Audio):"') do if not defined %%a set "%%a=%%a" & echo audioinfo=%%a
  24. pause
复制代码

TOP

1.把代码中的所有echo修改为set;
2.在pause上面加上下面几行代码:
  1. set CPUName
  2. set Memory
  3. set VideoAdapter
  4. set MotherboardInfo
  5. set monitor
  6. set Diskinfo
  7. set audioinfo
复制代码

TOP

本帖最后由 yakeyun 于 2022-7-25 14:34 编辑

回复 4# qixiaobin0715

内存数量和每条内存信息会对不上
  1. @echo off & setlocal enabledelayedexpansion
  2. cd /d "%~dp0"
  3. for /f  "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[overviewinfowrapper] CPUName :"') do if not defined %%a set "%%a=%%a" & set CPUName=%%a
  4. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do set MemoryNumber=%%a
  5. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.0"') do set Memory0Name=%%a
  6. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory1Name=%%a
  7. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory2Name=%%a
  8. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory3Name=%%a
  9. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[gpuprocesser] VideoAdapter"') do if not defined %%a set "%%a=%%a" & set VideoAdapter=%%a
  10. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[motherboardinfowrapper] GetMotherboardInfo:"') do if not defined %%a set "%%a=%%a" & set MotherboardInfo=%%a
  11. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[monitorinfowrapper] find primary monitor"') do if not defined %%a set "%%a=%%a" & set monitor=%%a
  12. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[disk_client] PrimarayDiskModel:"') do if not defined %%a set "%%a=%%a" & set Diskinfo=%%a
  13. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] ="') do  if not defined %%a set "%%a=%%a" & set Network0=%%a
  14. for /f "tokens=2* delims==" %%b in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] ="') do if not defined %%b set "%%b=%%b" & set Network1=%%b
  15. for /f "tokens=2* delims==" %%c in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] ="') do if not defined %%c set "%%c=%%c" & set Network2=%%c
  16. for /f "tokens=2* delims=@" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[audioinfo] Multimedia(Hi-definition Audio):"') do if not defined %%a set "%%a=%%a" & set audioinfo=%%a
  17. set CPUName
  18. set MemoryNumber
  19. set Memory0Name
  20. set Memory1Name
  21. set Memory2Name
  22. set Memory3Name
  23. set VideoAdapter
  24. set MotherboardInfo
  25. set monitor
  26. set Diskinfo
  27. set Network0
  28. set Network1
  29. set Network2
  30. set audioinfo
  31. pause
复制代码

TOP

不需要0123:
  1. set CPUName
  2. set Memory
  3. set VideoAdapter
  4. set MotherboardInfo
  5. set monitor
  6. set Diskinfo
  7. set Network
  8. set audioinfo
复制代码

TOP

本帖最后由 yakeyun 于 2022-7-25 15:23 编辑

回复 6# qixiaobin0715

如果存在多个硬盘的情况下,就无法正常输出硬盘,只会显示最后一个。
  1. @echo off & setlocal enabledelayedexpansion
  2. pushd "C:\Program Files (x86)\LuDaShi\log"
  3. for /f  "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[overviewinfowrapper] CPUName :"') do if not defined %%a set "%%a=%%a" & set CPUName=%%a
  4. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do set MemoryNumber=%%a
  5. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview."') do set MemoryName=%%a
  6. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[gpuprocesser] VideoAdapter"') do if not defined %%a set "%%a=%%a" & set VideoAdapter=%%a
  7. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[motherboardinfowrapper] GetMotherboardInfo:"') do if not defined %%a set "%%a=%%a" & set MotherboardInfo=%%a
  8. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[monitorinfowrapper] find primary monitor"') do if not defined %%a set "%%a=%%a" & set monitor=%%a
  9. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[disk_client] PrimarayDiskModel:"') do if not defined %%a set "%%a=%%a" & set Diskinfo=%%a
  10. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription"') do  if not defined %%a set "%%a=%%a" & set Network=%%a
  11. for /f "tokens=2* delims=@" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[audioinfo] Multimedia(Hi-definition Audio):"') do if not defined %%a set "%%a=%%a" & set audioinfo=%%a
  12. set CPUName
  13. set MemoryNumber
  14. set MemoryName
  15. set VideoAdapter
  16. set MotherboardInfo
  17. set monitor
  18. set Diskinfo
  19. set Network
  20. set audioinfo
  21. pause
复制代码

TOP

本帖最后由 qixiaobin0715 于 2022-7-25 16:08 编辑

我是说按照顶楼的代码进行修改.

TOP

回复 8# qixiaobin0715

修改了下,加入判断内存条数条件后可以正常输出:
  1. @echo off & setlocal enabledelayedexpansion
  2. cd /d "%~dp0"
  3. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[overviewinfowrapper] CPUName :"') do set CPUName=%%a
  4. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do set MemoryNumber=%%a
  5. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.0"') do set Memory0Name=%%a
  6. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory1Name=%%a
  7. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.2"') do set Memory2Name=%%a
  8. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.3"') do set Memory3Name=%%a
  9. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[gpuprocesser] VideoAdapter"') do set VideoAdapter=%%a
  10. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[motherboardinfowrapper] GetMotherboardInfo:"') do set MotherboardInfo=%%a
  11. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[monitorinfowrapper] find primary monitor"') do set monitor=%%a
  12. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[disk_client] PrimarayDiskModel:"') do set Diskinfo=%%a
  13. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] ="') do set Diskinfo0=%%a
  14. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] ="') do set Diskinfo1=%%a
  15. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] ="') do set Diskinfo2=%%a
  16. for /f "tokens=2* delims=@" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[audioinfo] Multimedia(Hi-definition Audio):"') do set audioinfo=%%a
  17. set CPUName
  18. set MemoryNumber
  19. if !MemoryNumber! EQU 1 set Memory0Name
  20. if !MemoryNumber! EQU 2 set Memory0Name & set Memory1Name
  21. if !MemoryNumber! EQU 3 set Memory0Name & set Memory1Name & set Memory2Name
  22. if !MemoryNumber! EQU 4 set Memory0Name & set Memory1Name & set Memory2Name & set Memory3Name
  23. set VideoAdapter
  24. set MotherboardInfo
  25. set monitor
  26. set Diskinfo
  27. set audioinfo
  28. pause
复制代码

TOP

为什么非要用type...^|find...形式呢?直接用findstr不行吗?比如顶楼第三行,你使用了:
  1. type "ComputerZ_HardwareDll.log" ^|find/i "[overviewinfowrapper] CPUName :"
复制代码
可改为:
  1. findstr /i /l /c:"[overviewinfowrapper] CPUName :" "ComputerZ_HardwareDll.log"
复制代码
这样不知是否可行?效率是否要高一些?

TOP

回复 10# qixiaobin0715


用findstr 会显示没有定义:
  1. @echo off & setlocal enabledelayedexpansion
  2. pushd "C:\Program Files (x86)\LuDaShi\log"
  3. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[overviewinfowrapper] CPUName :" "ComputerZ_HardwareDll.log"') do set CPUName=%%a
  4. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] Spd count:" "ComputerZ_HardwareDll.log"') do set MemoryNumber=%%a
  5. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.0" "ComputerZ_HardwareDll.log"') do set Memory0Name=%%a
  6. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.1" "ComputerZ_HardwareDll.log"') do set Memory1Name=%%a
  7. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.2" "ComputerZ_HardwareDll.log"') do set Memory2Name=%%a
  8. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.3" "ComputerZ_HardwareDll.log"') do set Memory3Name=%%a
  9. for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[gpuprocesser] VideoAdapter" "ComputerZ_HardwareDll.log"') do set VideoAdapter=%%a
  10. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[motherboardinfowrapper] GetMotherboardInfo:" "ComputerZ_HardwareDll.log"') do set MotherboardInfo=%%a
  11. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[monitorinfowrapper] find primary monitor" "ComputerZ_HardwareDll.log"') do set monitor=%%a
  12. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[disk_client] PrimarayDiskModel:" "ComputerZ_HardwareDll.log"') do set Diskinfo=%%a
  13. for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] =" "ComputerZ_HardwareDll.log"') do set Network0=%%a
  14. for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] =" "ComputerZ_HardwareDll.log"') do set Network1=%%a
  15. for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] =" "ComputerZ_HardwareDll.log"') do set Network2=%%a
  16. for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[audioinfo] Multimedia(Hi-definition Audio):" "ComputerZ_HardwareDll.log"') do set audioinfo=%%a
  17. set CPUName
  18. set MemoryNumber
  19. if !MemoryNumber! EQU 1 set Memory0Name
  20. if !MemoryNumber! EQU 2 set Memory0Name & set Memory1Name
  21. if !MemoryNumber! EQU 3 set Memory0Name & set Memory1Name & set Memory2Name
  22. if !MemoryNumber! EQU 4 set Memory0Name & set Memory1Name & set Memory2Name & set Memory3Name
  23. set VideoAdapter
  24. set MotherboardInfo
  25. set monitor
  26. set Diskinfo
  27. set Network0
  28. set Network1
  29. set Network2
  30. set audioinfo
  31. pause
复制代码

TOP

本帖最后由 yakeyun 于 2022-7-26 00:40 编辑

回复 11# yakeyun

自己慢慢摸索,差不多已经找到最完美的方案了。加入if defined命令,避免出现获取不到信息,显示异常情况。
  1. @echo off & setlocal enabledelayedexpansion
  2. pushd "C:\Program Files (x86)\LuDaShi\log"
  3. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[overviewinfowrapper] CPUName :"') do set CPUName=%%a
  4. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] Spd count:"') do set MemoryNumber=%%a
  5. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] SpdOverview.0"') do set Memory0Name=%%a
  6. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] SpdOverview.1"') do set Memory1Name=%%a
  7. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] SpdOverview.2"') do set Memory2Name=%%a
  8. for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] SpdOverview.3"') do set Memory3Name=%%a
  9. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[gpuprocesser] VideoAdapter"') do set VideoAdapter=%%a
  10. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[motherboardinfowrapper] GetMotherboardInfo:"') do set MotherboardInfo=%%a
  11. for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[monitorinfowrapper] find primary monitor"') do set monitor=%%a
  12. for /f "tokens=1 delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i /c "[disk_client] ModelNumber"') do set DiskNumber=%%a
  13. for /f "tokens=1 delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i /c "[disk_client] ModelNumber"') do set DiskNumber=%%a
  14. if !DiskNumber! EQU 1 (for /f "tokens=3* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[disk_client] ModelNumber"') do set Disk0Number=%%a)
  15. if !DiskNumber! EQU 2 (for /f "tokens=3* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[disk_client] ModelNumber"') do (
  16. set /a n+=1
  17. set /a num=n%%!DiskNumber!
  18. if !num! EQU 0 set Disk0Number=%%a
  19. if !num! EQU 1 set Disk1Number=%%a
  20. ))
  21. if !DiskNumber! EQU 3 (for /f "tokens=3* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[disk_client] ModelNumber"') do (
  22. set /a n+=1
  23. set /a num=n%%!DiskNumber!
  24. if !num! EQU 0 set Disk0Number=%%a
  25. if !num! EQU 1 set Disk1Number=%%a
  26. if !num! EQU 2 set Disk2Number=%%a
  27. ))
  28. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0]"') do set Network0=%%a
  29. for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1]"') do set Network1=%%a
  30. for /f "tokens=6* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "Realtek High Definition Audio"') do set audio0=%%a
  31. if defined CPUName set CPUName
  32. if defined MemoryNumber set MemoryNumber
  33. if !MemoryNumber! EQU 1 set Memory0Name
  34. if !MemoryNumber! EQU 2 set Memory0Name & set Memory1Name
  35. if !MemoryNumber! EQU 3 set Memory0Name & set Memory1Name & set Memory2Name
  36. if !MemoryNumber! EQU 4 set Memory0Name & set Memory1Name & set Memory2Name & set Memory3Name
  37. if defined VideoAdapter set VideoAdapter
  38. if defined MotherboardInfo set MotherboardInfo
  39. if defined monitor set monitor
  40. if defined DiskNumber set DiskNumber
  41. if !DiskNumber! EQU 1 set Disk0Number
  42. if !DiskNumber! EQU 2 set Disk0Number & set Disk1Number
  43. if !DiskNumber! EQU 3 set Disk0Number & set Disk1Number & set Disk2Number
  44. if defined Network0 set Network0
  45. if defined Network1 set Network1
  46. if defined audio0 set audio0
  47. pause
复制代码

TOP

回复 3# yakeyun


请注意,2楼的绝大多数代码服务于关于键字“GetPCVendor”的“去重”,其实只要把“去重”代码服稍作修改从而务于其它各关键字就能出结果

TOP

回复 11# yakeyun
1.你的要求没有说清楚;
2.代码没有写对。
按你的代码形式可以这样:
  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[overviewinfowrapper] CPUName :" "ComputerZ_HardwareDll.log"') do set CPUName=%%a
  3. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] Spd count:" "ComputerZ_HardwareDll.log"') do set Memory Number=%%a
  4. for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.0" "ComputerZ_HardwareDll.log"') do set Memory0Name=%%a
  5. for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.1" "ComputerZ_HardwareDll.log"') do set Memory1Name=%%a
  6. for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.2" "ComputerZ_HardwareDll.log"') do set Memory2Name=%%a
  7. for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.3" "ComputerZ_HardwareDll.log"') do set Memory3Name=%%a
  8. for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[gpuprocesser] VideoAdapter" "ComputerZ_HardwareDll.log"') do set VideoAdapter=%%a
  9. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[motherboardinfowrapper] GetMotherboardInfo:" "ComputerZ_HardwareDll.log"') do set MotherboardInfo=%%a
  10. for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[monitorinfowrapper] find primary monitor" "ComputerZ_HardwareDll.log"') do set monitor=%%a
  11. set DiskNumber=0
  12. for /f "tokens=3* delims==" %%a in ('findstr /i /l /c:"[disk_client] ModelNumber" "ComputerZ_HardwareDll.log"') do (
  13. set Disk!DiskNumber!Number=%%a
  14. set /a DiskNumber+=1
  15. )
  16. set Disk Number=!DiskNumber!
  17. set DiskNumber=
  18. for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] =" "ComputerZ_HardwareDll.log"') do set Network0=%%a
  19. for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] =" "ComputerZ_HardwareDll.log"') do set Network1=%%a
  20. for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] =" "ComputerZ_HardwareDll.log"') do set Network2=%%a
  21. for /f "tokens=2* delims=@" %%a in ('findstr /i /l /c:"[audioinfo] Multimedia(Hi-definition Audio):" "ComputerZ_HardwareDll.log"') do set audioinfo=%%a
  22. set CPUName
  23. set Memory
  24. set VideoAdapter
  25. set MotherboardInfo
  26. set monitor
  27. set Disk
  28. set Network
  29. set audioinfo
  30. pause
复制代码
1

评分人数

TOP

可以一次读取所有符合条件的行,再分别处理。这样效率就会高很多。

TOP

返回列表