Sunny
Sunny

Reputation: 8312

Changing the format of WMIC result

I am using below command to get system memory in Output.txt file:

wmic OS get TotalVisibleMemorySize,FreePhysicalMemory > Output.txt

memory is coming in Output.txt file in below format:

FreePhysicalMemory  TotalVisibleMemorySize  
828556                   2061560       

But i want, it should come like:

FreePhysicalMemory=      828556   
TotalVisibleMemorySize=  2061560    

I tried some changes in command but not getting the output in required format and don't want to use systeminfo command as it takes time.

EDIT1:

Using both the below commands i am getting following output, but i want to add a single space after those equal signs(=)...:)

wmic OS get FreePhysicalMemory,TotalVisibleMemorySize /Format:Textvaluelist > Output.txt

wmic OS get FreePhysicalMemory,TotalVisibleMemorySize /Format:Wmiclivalueformat > Output.txt

Output.txt:

FreePhysicalMemory=851528
TotalVisibleMemorySize=2061560

I am trying with below but not working..

For /F "tokens=1 delims==" %%A in ('wmic OS get FreePhysicalMemory,TotalVisibleMemorySize /Format:Textvaluelist') do 
echo %%A %%B > Output.txt  

Upvotes: 2

Views: 3780

Answers (2)

Angus Connell
Angus Connell

Reputation: 419

Sorry not much of an answer as it's not DOS based, But why don't you use a powershell script?

 $test = gwmi win32_OperatingSystem
 "TotalVisibleMemorySize = " + $test.TotalVisibleMemorySize
 "FreePhysicalMemory = " + $test.FreePhysicalMemory

Also check out Why is FreePhysicalMemory giving an incorrect value?

Upvotes: 1

npocmaka
npocmaka

Reputation: 57252

Check this here. What is closest to what you want shoud be:

wmic OS get TotalVisibleMemorySize,FreePhysicalMemory /Format:Wmiclitableformatnosys

But better test them all , or define your own.

Upvotes: 4

Related Questions