Memory usage percentage to txt file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Memory usage percentage to txt file

#1 Post by mohdfraz » 28 Feb 2015 02:13

Hello,

I want to get Memory Usage percentage to c:\Memory.txt through batch file.

I am using windows 8 and want the Memory usage percentage identical as showing in Task Manager.

Thanks

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Memory usage percentage to txt file

#2 Post by Compo » 28 Feb 2015 05:59

I'm not sure if this will exactly match the figure you're looking for, but give it a try:

Code: Select all

@Echo Off
SetLocal EnableExtensions
For /F "Skip=1 Tokens=*" %%A In (
   'WMIc OS Get FreePhysicalMemory^,TotalVisibleMemorySize') Do (
   For %%B In (%%A) Do If Not Defined _ (Set/A _=100*%%B) Else (Set/A _=_/%%B)
)
Echo(Free Memory = %_%%%>C:\Memory.txt

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Memory usage percentage to txt file

#3 Post by mohdfraz » 28 Feb 2015 06:19

Compo wrote:I'm not sure if this will exactly match the figure you're looking for, but give it a try:

Code: Select all

@Echo Off
SetLocal EnableExtensions
For /F "Skip=1 Tokens=*" %%A In (
   'WMIc OS Get FreePhysicalMemory^,TotalVisibleMemorySize') Do (
   For %%B In (%%A) Do If Not Defined _ (Set/A _=100*%%B) Else (Set/A _=_/%%B)
)
Echo(Free Memory = %_%%%>C:\Memory.txt



Compo,

Wahoo,, Very nice,,, Thank you very much.

Its not exactly matching but giving +/- 6% which is also good.

Thanks

Post Reply