wmic OS get FreePhysicalMemory,TotalVisibleMemorySize /Format:Textvaluelist > Output.txt
Using above command in a batch, I get output as,
Wmic can be a weird beast. This works here in Windows 8 32 bit.
The extra code is needed to remove the trailing Carriage Return.
@echo off
setlocal enabledelayedexpansion
(For /F "tokens=1,* delims==" %%A in ('"wmic OS get FreePhysicalMemory,TotalVisibleMemorySize /value |find "M" "') do (
set "line=%%A= %%B"
set "line=!line:~0,-1!"
echo !line!
))>output.txt
First you would consider to convert the WMIC
output encoding from Unicode
to ANSI
to ommit unicode characters (like empty Echoes), a simple trick to do this is filtering the output with FIND/FINDSTR
command(s), after applying the output filter you just need to read the output with FOR /F
to split the string using the desired tokens
value and delims
delimitter.
Here is the code:
@Echo OFF
(For /F "Tokens=1,* Delims==" %%A in (
'wmic OS get FreePhysicalMemory^,TotalVisibleMemorySize /Format:list ^| FINDSTR "[0-9]"'
)DO (
Echo %%A= %%B
))>"File.txt"
Pause&Exit