1.

Solve : Detect RAM with Batch file?

Answer»

Hello everyone,
I'm new here in this community, I need some help with a batch FILE :b.
What I am trying to do is make a Batch File that can detects the total RAM of the system and if its less that, for example 384 MB DO "myapp.exe" IF NOT do "myotherapp.exe"

I already have some of it:
Code: [Select]systeminfo | findstr /c:"Cantidad total de memoria física:" > memtot.txt
My OS is in Spanish so systeminfo gives me that string , it means "Total physcal memory"

I think that the next move will be take the number from the created "memtot.txt" and make it into a variable for compare.. but i don't have an idea how do that :b...

Sorry for my English.
Thanks.
No need for temp file; FOR will parse output of systeminfo directly

Code: [Select]
echo off

for /f "tokens=1-6 delims=: " %%A in ( ' type systeminfo.txt ^| find "Cantidad total de memoria física" ' ) do set ramsize=%%F

REM if your local settings use a comma as thousands separator you must remove it

set ramsize=%ramsize:,=%

echo ramsize %ramsize% MB

if %ramsize% LSS 384 (

myapp.exe

) ELSE (

myotherapp.exe

)

Thank you very much Salmon, here is the code as it works:
Code: [Select]echo off

systeminfo | findstr /c:"Cantidad total de memoria física:" > RAM.TXT

for /f "tokens=1-7 delims= " %%a in (RAM.TXT) do set ramsizedot=%%f

set ramsize=%ramsizedot:.=%

echo RAM SIZE IS: %ramsize% MB

echo.
echo.
echo.

if %ramSIZE% LSS 382 (

echo --- THIS SYSTEM HAS LESS THAT 382 OF RAM ---
) else (

echo --- THIS SYSTEM HAS MORE THAT 382 OF RAM ---
)
del RAM.TXT

I tried to do it without the need of a temp file but im very noob in this. :b¡Muy bien! ¡Que bonita!

Maybe you could try this line and if it works you don't need the file

Code: [Select]for /f "tokens=1-7 delims= " %%a in ( ' systeminfo ^| find "Cantidad total de memoria física" ' ) do set ramsizedot=%%f
I am LEARNING Spanish, I know how to say joder and some other things...
No, it doesn't. well i will use the temp file, its not a big DEAL...

This will be useful for my unnatended setups 

Im glad that you can say me sh*t in spanish too... just KIDDING... LOL Quote from: DJ Iñaki on March 31, 2010, 02:17:34 PM

Im glad that you can say me sh*t in spanish too... just kidding... LOL

joder means f*ck doesn't it? I know how to say me cago en d....... Like the priest in "La Caja" (a film I like)




Discussion

No Comment Found