[1]@echo off
[2]setlocal enabledelayedexpansion
[3]cd\
[4]set q1=WMIC SERVICE where "name like '%%svc%%'" get name^^,processid
[5]
[6]for /f "skip=1 tokens=1,2" %%a in ('%q1%') do (
[7] for /f "skip=1 tokens=1" %%j in (
[8] 'WMIC PROCESS where processid^='%%b' get workingsetsize'
[9] ) do (
[10] set /a sz=%%j/1024
[11] echo/%%a %%b !sz! KB
[12] )
[13])
[14]cmd /K
TIA
Matt
Have you tried something like ...
[4]set q1=WMIC SERVICE where "name like '%%svc%%'" get
name^^,processid^^|find " "
and
[8] 'WMIC PROCESS where processid^='%%b' get workingsetsize'|find "
"
Tom Lavedas
***********
http://there.is.no.more/tglbatch/
> [8] 'WMIC PROCESS where processid^='%%b' get workingsetsize'
WMIC is printing two carriage returns per line feed. Here's the hex output
of a sample:
C:\T>WMIC PROCESS where processid^='848' get workingsetsize|hex
HEX: +00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
0123456789abcdef
0000000000: 57 6F 72 6B 69 6E 67 53 65 74 53 69 7A 65 20 20 WorkingSetSize
0000000010: 0D 0D 0A 33 39 34 38 35 34 34 20 20 20 20 20 20 ...3948544
0000000020: 20 20 20 0D 0D 0A 0D 0D 0A ......
This is a programming error. If it was done inntentionally then the
programmer is the error.
One way to overcome this error is to break from FOR as soon as you get what
you need. Just add a label after FOR ind insert a break as follows:
> [1]@echo off
> [2]setlocal enabledelayedexpansion
> [3]cd\
> [4]set q1=WMIC SERVICE where "name like '%%svc%%'" get name^^,processid
> [5]
> [6]for /f "skip=1 tokens=1,2" %%a in ('%q1%') do (
> [7] for /f "skip=1 tokens=1" %%j in (
> [8] 'WMIC PROCESS where processid^='%%b' get workingsetsize'
> [9] ) do (
> [10] set /a sz=%%j/1024
> [11] echo/%%a %%b !sz! KB
Goto :Break
> [12] )
> [13])
:Break
> [14]cmd /K
Are you sure 'cmd /K' is useful?
Frank
Hmmm. I'd not be so rash as to make that assertion.
In the days of the ASR33 terminal, CRCRLF or CRLFCR was used to allow the
printhead time to travel back to the home position and settle. Without the
extra CR, it was possible for the first character(s) of the following line
to be printed before the printhead had reached the home position. In some
institutions, this standard has remained depite the advance in technology -
I mean, we're still using Hollerith's 80-column standard from the 1890 US
census...
If it's really a problem, perhaps SED s/\x0dx0dx0a/x0dx0a/g cound be used as
a remedy.
Aargh. Hollerith used a 24-column card. The 80-column "5081" standard card
was IBM's from 1928.
Not that I actually remember either from its introduction...
Try this without the nested for loops:
::----- START -----
[01]@Echo off
[02]Setlocal enableextensions
[03]For /f "skip=1 tokens=1-2" %%a In (
[04] 'Wmic service where "name like '%%svc%%'" get name^,processid') Do (
[05] Call :wss %%a %%b)
[06]Pause
[07]Goto :Eof
[08]
[09]:wss
[10]If %2' equ ' Goto :Eof
[11]For /f "skip=1 tokens=2 delims==" %%a In (
[12] 'Wmic process where processid^='%2' get workingsetsize /value') Do (
[13] Set sz=%%a)
[14]Set/a sz /=1024
[15]Echo/%1 %2 %sz% KB
::------ END ------
This breaks after the first iteration of the loop. I want results for
all matching services. I think this might work if I could put the label
between [12] and [13] but I can't put a label inside of the loop.
> Are you sure 'cmd /K' is useful?
When testing, I use it so I can just double click to run the script and
see results before the windows closes. Pause works too but I got tired
of looking for the 'any' key. ;)
Thank you my palindromic friend. This is much nicer.
Our ASR33s were well maintained, and a character could be properly
printed directly after a CR & LF (if in that order) after a long line.
The ASR38, with a wider carriage and a larger head (for lower-case)
needed at least one non-printing character after long-line CR LF. I
generally allowed three.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3 6.20 ; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
> Hmmm. I'd not be so rash as to make that assertion.
You are correct. I apologi<z/s>e to to either the program or the programmer.
Frank
--
If I seem to be a day behind it's because I transfer mail in the morning,
read and reply to it later in the day, then send those replies during the
next day's transfer.