标题: [系统相关] 求批处理修改获取内存条代码使得结果在一行内 [打印本页]
作者: jshuanya 时间: 2024-1-18 20:56 标题: 求批处理修改获取内存条代码使得结果在一行内
首先感谢showcode大神给我的如下代码,已经很完美了。可以获取内存条信息,多条内存也可以,获取到的结果范例为:
+++8GB+++
+++2400+++
+++8GB+++
+++3200+++
能否修改一下,使得结果为8GB,频率2400,8GB,频率3200在一行里显示呢- @echo off
- setlocal enabledelayedexpansion
- for /f "tokens=1-2 delims==" %%a in ('wmic MemoryChip get Capacity^,Speed /value ^| findstr "="') do (
- if "%%a" == "Capacity" (
- for %%c in (%%b) do (
- set "MemCap=%%c"
- )
- ) else if "%%a" == "Speed" (
- for %%c in (%%b) do (
- set "MemSpd=%%c"
- )
- for /f %%i in ('powershell "!MemCap!/(1024*1024*1024)"') do (
- set "MemCap=%%i"
- )
- echo +++!MemCap!GB+++
- echo +++!MemSpd!+++
- )
- )
- pause
复制代码
作者: newswan 时间: 2024-1-18 21:15
回复 1# jshuanya - @echo off
- setlocal enabledelayedexpansion
- for /f "tokens=1-2 delims==" %%a in ('wmic MemoryChip get Capacity^,Speed /value ^| findstr "="') do (
- if "%%a" == "Capacity" (
- for %%c in (%%b) do (
- set "MemCap=%%c"
- )
- for /f %%i in ('powershell "!MemCap!/(1024*1024*1024)"') do (
- set "MemCap=%%i"
- )
- set mem=!mem! 容量!MemCap!GB
- ) else if "%%a" == "Speed" (
- for %%c in (%%b) do (
- set "MemSpd=%%c"
- )
- set mem=!mem!,频率!MemSpd!
- )
- )
- echo %mem%
- pause
复制代码
作者: jshuanya 时间: 2024-1-19 09:04
回复 jshuanya
newswan 发表于 2024-1-18 21:15
谢谢你,可以用。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |