for /f constructions with default (space) delimiter put this number
into one token (this means, does not handle space used as separator as
a delimiter). Also construction (if "%e" GTR "30 000") failed, in case
token %e contain string "4 300" output of condition is TRUE.
Any ideas?
L.
I have some but it would help knowing what you are trying to parse, to
be able to give specific help.
You can split the text into multiple tokens and add them together into
one number.
When you use quotes this does an ascii compare.
> if "%e" GTR "30 000"
--
Regards,
Mic
If specific process consume over than specific amount of RAM, than
kill it and start again (restart process)
> You can split the text into multiple tokens and add them together into
> one number.
Yes, I can realize this, but I still wandering why thousand separator
space does not handled as delimiter in FOR loop.
> When you use quotes this does an ascii compare.
>
> > if "%e" GTR "30 000"
>
you are right, my fault
L.
This may work is you get pslist.exe from the PStools from Microsoft.
(untested)
The 500000 is in KB
@echo off
for /f "tokens=3" %%a in (
'pslist -m 2^>nul ^|find /i "firefox"'
) do (
echo virtual ram = "%%a"
if %%a GTR 500000 taskkill /F /IM firefox.exe
)
pause
--
Regards,
Mic
> If specific process consume over than specific amount of RAM, than
> kill it and start again (restart process)
I added a line below to restart firefox, just for completeness sake.
This may work if you get pslist.exe from the PStools from Microsoft.
(untested)
The 500000 is in KB
@echo off
for /f "tokens=3" %%a in (
'pslist -m 2^>nul ^|find /i "firefox"'
) do (
echo virtual ram = "%%a"
if %%a GTR 500000 taskkill /F /IM firefox.exe
start "" "c:\program files\firefox\firefox.exe"
)
--
Regards,
Mic
Ooh - be very careful.
That's only true for the current purpose if the strings are of equal length.
Demo:
@echo off
for %%i in (
"29 999" "31 000" 123 657 "4 000"
) do (
if "%%~i" gtr "30 000" (
echo %%~i is greater than 30 000) else (
echo %%~i is NOT greater than 30 000)
)
)
As already asked, we need to know exactly what you are trying to do!
You can parse the memory usage for a specific process directly in tasklist
without having to output it through a for loop.
:: - - - - - START - - - - -
TASKLIST /FI "MEMUSAGE gt 1048576" /FI "IMAGENAME eq FIREFOX.EXE"
/NH|FINDSTR/BI "FIREFOX.EXE">NUL 2>&1&&(ECHO=Running High)||(ECHO=Running
Okay)
:: - - - - - -END- - - - - -