
标题: 判断进程svchost.exe个数并显示出来 [打印本页]
作者: xue0808 时间: 2010-5-17 14:22 标题: 判断进程svchost.exe个数并显示出来
RT
3Q
作者: Hanyeguxing 时间: 2010-5-17 15:06
CODE: [Copy to clipboard]
@echo off
for /f "delims=" %%a in ('Tasklist /fi "Imagename eq svchost.exe"') do set/a a+=1&echo.%%a
set/a a-=2
echo.共计 %a% 个 svchost.exe&pause
或:CODE: [Copy to clipboard]
@echo off
for /f %%a in ('Tasklist /nh /fi "Imagename eq svchost.exe"') do set/a a+=1
echo.共计 %a% 个 svchost.exe&pause
或:CODE: [Copy to clipboard]
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%a in ('Tasklist /svc /fi "Imagename eq svchost.exe"') do echo.%%a&set a=%%a&if not "!a:~0,1!"==" " set/a n+=1
set/a n-=2
echo.共计 %n% 个 svchost.exe&pause
或:CODE: [Copy to clipboard]
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%a in ('Tasklist /m /fi "Imagename eq svchost.exe"') do echo.%%a&set a=%%a&if not "!a:~0,1!"==" " set/a n+=1
set/a n-=2
echo.共计 %n% 个 svchost.exe&pause
[ Last edited by Hanyeguxing on 2010-5-17 at 15:18 ]
作者: xue0808 时间: 2010-5-17 15:11
谢谢
好用
作者: xue0808 时间: 2010-5-17 16:12
set/a n-=2
为什么加这个???
作者: Hanyeguxing 时间: 2010-5-17 16:47
| Quote: |
Originally posted by xue0808 at 2010-5-17 16:12:
set/a n-=2
为什么加这个??? |
|
因为使用了set/a n-=2的这些示例,tasklist都没有使用/nh参数,即显示了2行的列标题,所以要减去
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) |
Powered by Discuz! 2.5 |