how can I convert wmic memorychip get SMBIOSMemoryType numerical value to name (DDR) and output to a txt file
I am currently in the process of writing a script to output information gathered from wmic etc to txt file or html file.
I know you can get the memory type ie DDR3, DDR4 etc with the command `wmic memorychip get SMBIOSMemoryType which shows the type in numerical value ie 26 for DDR4.
But is there a batch script that can be written to convert the value to show DDR3/ DDR4 etc and output it to a variable .
20 = DDR
21 = DDR2
22 = DDR2 FB-DIMM
24 = DDR3
26 = DDR4
I cant seem to add code in a comment box so i have updated this below to what i have found out.
This seems to work in principle.
for /F "skip=1" %%E in (' wmic memorychip get SMBIOSMemoryType ') do for /F %%F in ("%%E") do set "FF=%%F" if %FF% equ 26 ( goto ramtype1 ) if %FF% equ 24 ( goto ramtype2 ) if %FF% equ 21 ( goto ramtype3 ) else ( goto ramtype4 ) :ramtype1 echo DDR4 pause exit :ramtype2 echo DDR3 pause exit :ramtype3 echo DDR2 pause exit :ramtype4 echo other pause exit Pause
This code is similar.
for /F "skip=1" %%E in (' wmic memorychip get SMBIOSMemoryType ') do for /F %%F in ("%%E") do set "FF=%%F" if %FF% equ 26 ( echo Ram Type is DDR4. if %FF% equ 24 ( echo Ram Type is DDR4. ) ) else ( echo Unknown )
Need the above to work with the code below or similar.
if /i %opt%==1 echo !CODE HERE! >> "..\NCR_STAGING_LOGS\ASDA%STORENAME%%serial% %MAC%".html
Not having much look unfortunately
I would normally have the below to get wmic info and pass it to a %variable% like %Memtype% below but this obvioausly outputs 26 as DDR4.
set torun=wmic memorychip get SMBIOSMemoryType for /f "tokens=2 delims==" %%a in ('%torun%') do set MemType=%%a
Here is a single line example to be used within a batch-file, and which uses your specified
SMBIOSMemoryType property, (which is only available in Windows 10/Server 2016+).
(For %%G In ("1=DDR" "2=DDR2" "4=DDR3" "6=DDR4") Do Set "_2%%~G") & For /F EOL^=S %%H In ('%SystemRoot%\System32\wbem\WMIC.exe MemoryChip Where "SMBIOSMemoryType='20' Or SMBIOSMemoryType='21' Or SMBIOSMemoryType='24' Or SMBIOSMemoryType='26'" Get SMBIOSMemoryType 2^>NUL') Do For %%I In (%%H) Do For /F %%J ('%SystemRoot%\System32\cmd.exe /V /D /C "Echo(!_%%I!") Do Echo(%%J
Please also note, that your initial wmic query will output the same number of results as there are installed memory sticks. If you don’t want that, you’ll have to modify the code yourself as needed, because doing so is beyond the scope of your request to replace the uint32 data type results with their respective strings.
Answered By – Compo