标题: [文本处理] [交流]批处理如何通过鲁大师日志提取硬件信息,重复数据太多 [打印本页]
作者: yakeyun 时间: 2022-7-24 18:02 标题: [交流]批处理如何通过鲁大师日志提取硬件信息,重复数据太多
本帖最后由 yakeyun 于 2022-7-26 00:07 编辑
鲁大师运行后会在程序安装路径下生成一个日志文件:C:\Program Files (x86)\LuDaShi\Log\ComputerZ_HardwareDll.log
这个里面包含了所有主机里面的硬件信息,但是自己通过下面代码提取后,出现许多重复项,也找不到规律来很好的提取信息。- @echo off & setlocal enabledelayedexpansion
- pushd "C:\Program Files (x86)\LuDaShi\log"
-
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[overviewinfowrapper] CPUName :"') do set CPUName=%%a
-
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do set MemoryNumber=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.0"') do set Memory0Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory1Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.2"') do set Memory2Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.3"') do set Memory3Name=%%a
-
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[gpuprocesser] VideoAdapter"') do set VideoAdapter=%%a
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[motherboardinfowrapper] GetMotherboardInfo:"') do set MotherboardInfo=%%a
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[monitorinfowrapper] find primary monitor"') do set monitor=%%a
- for /f "tokens=3* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[disk_client] ModelNumber"') do set Diskinfo=%%a
-
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] ="') do set Network0=%%a
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] ="') do set Network1=%%a
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] ="') do set Network2=%%a
-
- for /f "tokens=2* delims=@" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[audioinfo] Multimedia(Hi-definition Audio):"') do set audioinfo=%%a
-
- set CPUName
- set MemoryNumber
- if !MemoryNumber! EQU 1 set Memory0Name
- if !MemoryNumber! EQU 2 set Memory0Name & set Memory1Name
- if !MemoryNumber! EQU 3 set Memory0Name & set Memory1Name & set Memory2Name
- if !MemoryNumber! EQU 4 set Memory0Name & set Memory1Name & set Memory2Name & set Memory3Name
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Diskinfo
- set Network0
- set Network1
- set Network2
- set audioinfo
-
- 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 控制器
作者: hfxiang 时间: 2022-7-24 19:34
@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"
)
)
作者: yakeyun 时间: 2022-7-25 13:19
本帖最后由 yakeyun 于 2022-7-25 13:25 编辑
回复 2# hfxiang
可以过滤,不过后面自己修改了下,获取后依然存在重复项。修改后的代码如下:- @echo off & setlocal enabledelayedexpansion
- cd /d "%~dp0"
- echo.
- echo.
- 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
- echo.
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do echo MemoryNumber=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.0"') do echo Memory0Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do echo Memory1Name=%%a
- echo.
- 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
- echo.
- 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
- echo.
- 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
- echo.
- 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
- echo.
- 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
- 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
- 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
- echo.
- 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
-
- pause
复制代码
作者: qixiaobin0715 时间: 2022-7-25 13:53
1.把代码中的所有echo修改为set;
2.在pause上面加上下面几行代码:- set CPUName
- set Memory
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Diskinfo
- set audioinfo
复制代码
作者: yakeyun 时间: 2022-7-25 14:08
本帖最后由 yakeyun 于 2022-7-25 14:34 编辑
回复 4# qixiaobin0715
内存数量和每条内存信息会对不上- @echo off & setlocal enabledelayedexpansion
- cd /d "%~dp0"
-
- 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
-
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do set MemoryNumber=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.0"') do set Memory0Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory1Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory2Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory3Name=%%a
-
- 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
-
- 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
-
- 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
-
- 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
-
- 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
- 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
- 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
-
- 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
-
- set CPUName
- set MemoryNumber
- set Memory0Name
- set Memory1Name
- set Memory2Name
- set Memory3Name
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Diskinfo
- set Network0
- set Network1
- set Network2
- set audioinfo
-
- pause
复制代码
作者: qixiaobin0715 时间: 2022-7-25 14:32
不需要0123:- set CPUName
- set Memory
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Diskinfo
- set Network
- set audioinfo
复制代码
作者: yakeyun 时间: 2022-7-25 15:14
本帖最后由 yakeyun 于 2022-7-25 15:23 编辑
回复 6# qixiaobin0715
如果存在多个硬盘的情况下,就无法正常输出硬盘,只会显示最后一个。- @echo off & setlocal enabledelayedexpansion
- pushd "C:\Program Files (x86)\LuDaShi\log"
-
- 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
-
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do set MemoryNumber=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview."') do set MemoryName=%%a
-
- 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
-
- 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
-
- 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
-
- 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
-
- 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
-
-
- 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
-
- set CPUName
- set MemoryNumber
- set MemoryName
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Diskinfo
- set Network
- set audioinfo
-
- pause
复制代码
作者: qixiaobin0715 时间: 2022-7-25 15:53
本帖最后由 qixiaobin0715 于 2022-7-25 16:08 编辑
我是说按照顶楼的代码进行修改.
作者: yakeyun 时间: 2022-7-25 16:05
回复 8# qixiaobin0715
修改了下,加入判断内存条数条件后可以正常输出:- @echo off & setlocal enabledelayedexpansion
- cd /d "%~dp0"
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[overviewinfowrapper] CPUName :"') do set CPUName=%%a
-
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] Spd count:"') do set MemoryNumber=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.0"') do set Memory0Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.1"') do set Memory1Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.2"') do set Memory2Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[processmemory] SpdOverview.3"') do set Memory3Name=%%a
-
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[gpuprocesser] VideoAdapter"') do set VideoAdapter=%%a
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[motherboardinfowrapper] GetMotherboardInfo:"') do set MotherboardInfo=%%a
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[monitorinfowrapper] find primary monitor"') do set monitor=%%a
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[disk_client] PrimarayDiskModel:"') do set Diskinfo=%%a
-
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] ="') do set Diskinfo0=%%a
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] ="') do set Diskinfo1=%%a
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] ="') do set Diskinfo2=%%a
-
- for /f "tokens=2* delims=@" %%a in ('type "ComputerZ_HardwareDll.log" ^|find/i "[audioinfo] Multimedia(Hi-definition Audio):"') do set audioinfo=%%a
-
- set CPUName
- set MemoryNumber
- if !MemoryNumber! EQU 1 set Memory0Name
- if !MemoryNumber! EQU 2 set Memory0Name & set Memory1Name
- if !MemoryNumber! EQU 3 set Memory0Name & set Memory1Name & set Memory2Name
- if !MemoryNumber! EQU 4 set Memory0Name & set Memory1Name & set Memory2Name & set Memory3Name
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Diskinfo
- set audioinfo
-
- pause
复制代码
作者: qixiaobin0715 时间: 2022-7-25 16:28
为什么非要用type...^|find...形式呢?直接用findstr不行吗?比如顶楼第三行,你使用了:- type "ComputerZ_HardwareDll.log" ^|find/i "[overviewinfowrapper] CPUName :"
复制代码
可改为:- findstr /i /l /c:"[overviewinfowrapper] CPUName :" "ComputerZ_HardwareDll.log"
复制代码
这样不知是否可行?效率是否要高一些?
作者: yakeyun 时间: 2022-7-25 18:40
回复 10# qixiaobin0715
用findstr 会显示没有定义:- @echo off & setlocal enabledelayedexpansion
- pushd "C:\Program Files (x86)\LuDaShi\log"
-
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[overviewinfowrapper] CPUName :" "ComputerZ_HardwareDll.log"') do set CPUName=%%a
-
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] Spd count:" "ComputerZ_HardwareDll.log"') do set MemoryNumber=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.0" "ComputerZ_HardwareDll.log"') do set Memory0Name=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.1" "ComputerZ_HardwareDll.log"') do set Memory1Name=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.2" "ComputerZ_HardwareDll.log"') do set Memory2Name=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.3" "ComputerZ_HardwareDll.log"') do set Memory3Name=%%a
-
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[gpuprocesser] VideoAdapter" "ComputerZ_HardwareDll.log"') do set VideoAdapter=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[motherboardinfowrapper] GetMotherboardInfo:" "ComputerZ_HardwareDll.log"') do set MotherboardInfo=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[monitorinfowrapper] find primary monitor" "ComputerZ_HardwareDll.log"') do set monitor=%%a
-
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[disk_client] PrimarayDiskModel:" "ComputerZ_HardwareDll.log"') do set Diskinfo=%%a
-
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] =" "ComputerZ_HardwareDll.log"') do set Network0=%%a
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] =" "ComputerZ_HardwareDll.log"') do set Network1=%%a
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] =" "ComputerZ_HardwareDll.log"') do set Network2=%%a
-
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[audioinfo] Multimedia(Hi-definition Audio):" "ComputerZ_HardwareDll.log"') do set audioinfo=%%a
-
- set CPUName
- set MemoryNumber
- if !MemoryNumber! EQU 1 set Memory0Name
- if !MemoryNumber! EQU 2 set Memory0Name & set Memory1Name
- if !MemoryNumber! EQU 3 set Memory0Name & set Memory1Name & set Memory2Name
- if !MemoryNumber! EQU 4 set Memory0Name & set Memory1Name & set Memory2Name & set Memory3Name
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Diskinfo
- set Network0
- set Network1
- set Network2
- set audioinfo
-
- pause
复制代码
作者: yakeyun 时间: 2022-7-25 23:45
本帖最后由 yakeyun 于 2022-7-26 00:40 编辑
回复 11# yakeyun
自己慢慢摸索,差不多已经找到最完美的方案了。加入if defined命令,避免出现获取不到信息,显示异常情况。- @echo off & setlocal enabledelayedexpansion
- pushd "C:\Program Files (x86)\LuDaShi\log"
-
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[overviewinfowrapper] CPUName :"') do set CPUName=%%a
-
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] Spd count:"') do set MemoryNumber=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] SpdOverview.0"') do set Memory0Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] SpdOverview.1"') do set Memory1Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] SpdOverview.2"') do set Memory2Name=%%a
- for /f "tokens=4* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[processmemory] SpdOverview.3"') do set Memory3Name=%%a
-
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[gpuprocesser] VideoAdapter"') do set VideoAdapter=%%a
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[motherboardinfowrapper] GetMotherboardInfo:"') do set MotherboardInfo=%%a
- for /f "tokens=4* delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[monitorinfowrapper] find primary monitor"') do set monitor=%%a
- for /f "tokens=1 delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i /c "[disk_client] ModelNumber"') do set DiskNumber=%%a
- for /f "tokens=1 delims=:" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i /c "[disk_client] ModelNumber"') do set DiskNumber=%%a
- if !DiskNumber! EQU 1 (for /f "tokens=3* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[disk_client] ModelNumber"') do set Disk0Number=%%a)
- if !DiskNumber! EQU 2 (for /f "tokens=3* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[disk_client] ModelNumber"') do (
- set /a n+=1
- set /a num=n%%!DiskNumber!
- if !num! EQU 0 set Disk0Number=%%a
- if !num! EQU 1 set Disk1Number=%%a
- ))
- if !DiskNumber! EQU 3 (for /f "tokens=3* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[disk_client] ModelNumber"') do (
- set /a n+=1
- set /a num=n%%!DiskNumber!
- if !num! EQU 0 set Disk0Number=%%a
- if !num! EQU 1 set Disk1Number=%%a
- if !num! EQU 2 set Disk2Number=%%a
- ))
-
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0]"') do set Network0=%%a
- for /f "tokens=2* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1]"') do set Network1=%%a
- for /f "tokens=6* delims==" %%a in ('type "ComputerZ_HardwareDll.log" ^|find /i "Realtek High Definition Audio"') do set audio0=%%a
-
- if defined CPUName set CPUName
- if defined MemoryNumber set MemoryNumber
- if !MemoryNumber! EQU 1 set Memory0Name
- if !MemoryNumber! EQU 2 set Memory0Name & set Memory1Name
- if !MemoryNumber! EQU 3 set Memory0Name & set Memory1Name & set Memory2Name
- if !MemoryNumber! EQU 4 set Memory0Name & set Memory1Name & set Memory2Name & set Memory3Name
- if defined VideoAdapter set VideoAdapter
- if defined MotherboardInfo set MotherboardInfo
- if defined monitor set monitor
- if defined DiskNumber set DiskNumber
- if !DiskNumber! EQU 1 set Disk0Number
- if !DiskNumber! EQU 2 set Disk0Number & set Disk1Number
- if !DiskNumber! EQU 3 set Disk0Number & set Disk1Number & set Disk2Number
- if defined Network0 set Network0
- if defined Network1 set Network1
- if defined audio0 set audio0
-
- pause
复制代码
作者: hfxiang 时间: 2022-7-26 09:11
回复 3# yakeyun
请注意,2楼的绝大多数代码服务于关于键字“GetPCVendor”的“去重”,其实只要把“去重”代码服稍作修改从而务于其它各关键字就能出结果
作者: qixiaobin0715 时间: 2022-7-26 10:11
回复 11# yakeyun
1.你的要求没有说清楚;
2.代码没有写对。
按你的代码形式可以这样:- @echo off&setlocal enabledelayedexpansion
-
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[overviewinfowrapper] CPUName :" "ComputerZ_HardwareDll.log"') do set CPUName=%%a
-
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] Spd count:" "ComputerZ_HardwareDll.log"') do set Memory Number=%%a
- for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.0" "ComputerZ_HardwareDll.log"') do set Memory0Name=%%a
- for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.1" "ComputerZ_HardwareDll.log"') do set Memory1Name=%%a
- for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.2" "ComputerZ_HardwareDll.log"') do set Memory2Name=%%a
- for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.3" "ComputerZ_HardwareDll.log"') do set Memory3Name=%%a
-
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[gpuprocesser] VideoAdapter" "ComputerZ_HardwareDll.log"') do set VideoAdapter=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[motherboardinfowrapper] GetMotherboardInfo:" "ComputerZ_HardwareDll.log"') do set MotherboardInfo=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[monitorinfowrapper] find primary monitor" "ComputerZ_HardwareDll.log"') do set monitor=%%a
-
- set DiskNumber=0
- for /f "tokens=3* delims==" %%a in ('findstr /i /l /c:"[disk_client] ModelNumber" "ComputerZ_HardwareDll.log"') do (
- set Disk!DiskNumber!Number=%%a
- set /a DiskNumber+=1
- )
- set Disk Number=!DiskNumber!
- set DiskNumber=
-
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] =" "ComputerZ_HardwareDll.log"') do set Network0=%%a
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] =" "ComputerZ_HardwareDll.log"') do set Network1=%%a
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] =" "ComputerZ_HardwareDll.log"') do set Network2=%%a
-
- for /f "tokens=2* delims=@" %%a in ('findstr /i /l /c:"[audioinfo] Multimedia(Hi-definition Audio):" "ComputerZ_HardwareDll.log"') do set audioinfo=%%a
-
- set CPUName
- set Memory
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Disk
- set Network
- set audioinfo
- pause
复制代码
作者: qixiaobin0715 时间: 2022-7-26 10:46
可以一次读取所有符合条件的行,再分别处理。这样效率就会高很多。
作者: qixiaobin0715 时间: 2022-7-26 13:36
按照上面思路可以这样:- @echo off & setlocal enabledelayedexpansion
- set m=0
- set n=0
- set x=0
- set Order=findstr /i /l /c:"[overviewinfowrapper] CPUName :" /c:"[processmemory] SpdOverview." /c:"[gpuprocesser] VideoAdapter" /c:"[motherboardinfowrapper] GetMotherboardInfo:" /c:"[monitorinfowrapper] find primary monitor" /c:"[disk_client] ModelNumber" /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription" /c:"[audioinfo] Multimedia(Hi-definition Audio):" "ComputerZ_HardwareDll.log"
- for /f "tokens=9-12 delims=]:=" %%a in ('%Order%') do (
- set str=%%a
- set str=!str:~1,4!
- if "!str!"=="CPUN" (
- set CPUName=%%b
- ) else if "!str!"=="GetM" (
- set MotherboardInfo=%%b
- ) else if "!str!"=="GetN" (
- for /f "tokens=2 delims=[" %%i in ("%%b") do set Network%%i=%%d
- ) else if "!str!"=="Mode" (
- set Disk!m!Number=%%c
- set /a m+=1
- ) else if "!str!"=="Mult" (
- for /f "tokens=2 delims=@" %%i in ("%%b") do set audio!n!=%%i
- set /a n+=1
- ) else if "!str!"=="SpdO" (
- for /f "tokens=2 delims=. " %%i in ("%%a") do set Memory!x!Name=%%d
- set /a x+=1
- ) else if "!str!"=="Vide" (
- set VideoAdapter=%%b
- ) else if "!str!"=="find" (
- set monitor=%%b
- )
- )
- set CPUName
- set Memory
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Disk
- set Network
- set audio
- pause
复制代码
作者: yakeyun 时间: 2022-7-26 17:58
本帖最后由 yakeyun 于 2022-7-26 20:58 编辑
回复 14# qixiaobin0715
因为对findstr命令没有深入了解过,所以对用法不是很熟悉,感谢指导。
这个修改后的版本已经很完美了,不过对这种用法也是第一次了解到,在没有用echo命令,仅仅用set命令就可以将内容输出。- @echo off&setlocal enabledelayedexpansion
- pushd "C:\Program Files (x86)\LuDaShi\log"
- if exist "C:\Program Files (x86)\LuDaShi\log\ComputerZ_HardwareDll.log" (set top=[硬件参数])
-
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[overviewinfowrapper] CPUName :" "ComputerZ_HardwareDll.log"') do set CPUName=%%a
-
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[processmemory] Spd count:" "ComputerZ_HardwareDll.log"') do set Memory Number=%%a
- for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.0" "ComputerZ_HardwareDll.log"') do set Memory0Name=%%a
- for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.1" "ComputerZ_HardwareDll.log"') do set Memory1Name=%%a
- for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.2" "ComputerZ_HardwareDll.log"') do set Memory2Name=%%a
- for /f "tokens=4* delims==" %%a in ('findstr /i /l /c:"[processmemory] SpdOverview.3" "ComputerZ_HardwareDll.log"') do set Memory3Name=%%a
-
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[gpuprocesser] VideoAdapter" "ComputerZ_HardwareDll.log"') do set VideoAdapter=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[motherboardinfowrapper] GetMotherboardInfo:" "ComputerZ_HardwareDll.log"') do set MotherboardInfo=%%a
- for /f "tokens=4* delims=:" %%a in ('findstr /i /l /c:"[monitorinfowrapper] find primary monitor" "ComputerZ_HardwareDll.log"') do set monitor=%%a
-
- set DiskNumber=0
- for /f "tokens=3* delims==" %%a in ('findstr /i /l /c:"[disk_client] ModelNumber" "ComputerZ_HardwareDll.log"') do (
- set Disk!DiskNumber!Number=%%a
- set /a DiskNumber+=1
- )
- set Disk Number=!DiskNumber!
- set DiskNumber=
-
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[0] =" "ComputerZ_HardwareDll.log"') do set Network0=%%a & set Network Number=1
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[1] =" "ComputerZ_HardwareDll.log"') do set Network1=%%a & set Network Number=2
- for /f "tokens=2* delims==" %%a in ('findstr /i /l /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription[2] =" "ComputerZ_HardwareDll.log"') do set Network2=%%a & set Network Number=3
-
- set AudioNumber=0
- for /f "tokens=2* delims=@" %%a in ('findstr /i /l /c:"[audioinfo] Multimedia(Hi-definition Audio):" "ComputerZ_HardwareDll.log"') do (
- set Audio!AudioNumber!Number=%%a
- set /a AudioNumber+=1
- )
- set Audio Number=!AudioNumber!
- set AudioNumber=
-
- cd /d "%~dp0"
- (
- echo %top%
- set CPUName
- set Memory
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set Disk
- set Network Number
- set Network
- set audio
- )>sysinfo.ini
复制代码
有一点不是很理解:
如果将Network Number 改成NetworkNumber
set NetworkNumber
set Network
最后显示结果会变成:
NetworkNumber=2
Network0= 英特尔 Wi-Fi 6 AX201 160MHz
Network1= 瑞昱 Realtek Gaming 2.5GbE Family Controller / 华硕
NetworkNumber=2
Audio Number=2
NetworkNumber=2会出现2次。
鲁大师日志下载地址:
https://sanli.lanzoub.com/izxDU08g4k7g
作者: qixiaobin0715 时间: 2022-7-27 09:11
set和findstr用法可看这里http://bbs.bathome.net/viewthrea ... &from=favorites
不设置变量的set(不带等号和变量值),比如:
set a 显示以a开头的变量(包括环境变量及自定义变量)
set aa 显示以aa开头的变量
set aaa 显示以aaa开头的变量
同理
set Network 会显示以Network开头的所有变量包括NetworkNumber:- Network0= 英特尔 Wi-Fi 6 AX201 160MHz
- Network1= 瑞昱 Realtek Gaming 2.5GbE Family Controller / 华硕
- NetworkNumber=2
复制代码
变量会根据变量名的正序显示。NetworkNumber=2会最后一个显示。
而在前面你有一行
set NetworkNumber
也会显示变量NetworkNumber。就会产生重复的情况。
如果既不想重复显示,又要把变量NetworkNumber=2显示在Network0 Network1的前面。可以这样:- set NetworkNumber
- set NetworkNumber=
- set Network
复制代码
作者: qixiaobin0715 时间: 2022-7-27 11:01
本帖最后由 qixiaobin0715 于 2022-7-29 09:32 编辑
如果非要按照17楼的格式显示的话,可将16楼代码进行修改,效率要高不少,代码另存为ANSI编码:- @echo off & setlocal enabledelayedexpansion
- set DiskNumber=0
- set AudioNumber=0
- set MemoryNumber=0
- set Order=findstr /i /l /c:"[overviewinfowrapper] CPUName :" /c:"[processmemory] SpdOverview." /c:"[gpuprocesser] VideoAdapter" /c:"[motherboardinfowrapper] GetMotherboardInfo:" /c:"[monitorinfowrapper] find primary monitor" /c:"[disk_client] ModelNumber" /c:"[networkinfo] GetNetworkInfo: NetworkParams.strDescription" /c:"[audioinfo] Multimedia(Hi-definition Audio):" "ComputerZ_HardwareDll.log"
- for /f "tokens=9-12 delims=]:=" %%a in ('%Order%') do (
- set str=%%a
- set str=!str:~1,4!
- if "!str!"=="CPUN" (
- set CPUName=%%b
- ) else if "!str!"=="GetM" (
- set MotherboardInfo=%%b
- ) else if "!str!"=="GetN" (
- for /f "tokens=2 delims=[" %%i in ("%%b") do (
- if not defined _%%i (
- set /a NetworkNumber+=1
- set Network%%i=%%d
- set _%%i=true
- )
- )
- ) else if "!str!"=="Mode" (
- set Disk!DiskNumber!Number=%%c
- set /a DiskNumber+=1
- ) else if "!str!"=="Mult" (
- for /f "tokens=2 delims=@" %%i in ("%%b") do set Audio!AudioNumber!Number=%%i
- set /a AudioNumber+=1
- ) else if "!str!"=="SpdO" (
- for /f "tokens=2 delims=. " %%i in ("%%a") do set Memory!MemoryNumber!Name=%%d
- set /a MemoryNumber+=1
- ) else if "!str!"=="Vide" (
- set VideoAdapter=%%b
- ) else if "!str!"=="find" (
- set monitor=%%b
- )
- )
- echo [硬件参数]
- set CPUName
- set MemoryNumber
- set MemoryNumber=
- set Memory
- set VideoAdapter
- set MotherboardInfo
- set monitor
- set DiskNumber
- set DiskNumber=
- set Disk
- set NetworkNumber
- set NetworkNumber=
- set Network
- set AudioNumber
- set AudioNumber=
- set Audio
- pause
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |