[top-posting moved]
Hi Foxidrive
Thank you for your reply. I tried your suggestion, but it doesnt quite
work.
The result of command look like below:
C:\Documents and Settings\Default User>typeperf "Web
Service(_Total)\Anonymous Users/sec"|find "0.000000"&&call 2.bat
"09/14/2006 14:40:39.953","0.000000"
"09/14/2006 14:40:40.953","0.000000"
"09/14/2006 14:40:41.953","0.000000"
"09/14/2006 14:40:44.953","0.000000"
"09/14/2006 14:40:45.953","0.000000"
"09/14/2006 14:40:46.953","0.000000"
"09/14/2006 14:40:50.046","0.000000"
"09/14/2006 14:40:51.046","0.000000"
"09/14/2006 14:40:52.046","0.000000"
"09/14/2006 14:40:55.046","0.000000"
"09/14/2006 14:40:56.046","0.000000"
"09/14/2006 14:40:57.046","0.000000"
2.bat is a batch files to stop and disabled multiple Services.During
this process the 2.bat never got excuted (none of the listed Services
were stopped and disabled).
The issue is that TYPEPERF does not CLOSE the output stream until it
terminates, hence FIND cannot see its input.
Try
typeperf -sc 1 "Web Service(_Total)\Anonymous Users/sec"|find
"0.000000"&&call 2.bat
which will exit TYPEPERF after 1 second, executing 2.bat if the output
contains "0.000000"
From there, it's a simple matter of instigating a loop, preferably with some
variety of exit-trigger
[1]:loop
[2]if exist exit-trigger.flag del exit-trigger.flag&goto :eof
[3]typeperf -sc 1 "Web Service(_Total)\Anonymous Users/sec"|find
"0.000000"&&call 2.bat
[4]goto loop
4 lines, each labelled [number]
This way, to stop the batch all you need do is create a file called
"exit-trigger.flag" - which can naturally have any name you so desire.