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

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 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

@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

返回列表