Board logo

标题: 查找任务管理器的相同进程数量 [打印本页]

作者: fengzi     时间: 2008-5-17 15:07    标题: 查找任务管理器的相同进程数量

这几天机器狗病毒闹得厉害``
症状为任务管理器里面有两个explorer.exe
查找一个进程没问题``但是查找两个进程的代码我不知道该怎么写出来了
高手们给点提示`万分感谢`
作者: fastslz     时间: 2008-5-17 15:15
运行环境winxp 系统管理员身份
Wmic Process Where "Name='explorer.exe' And ExecutablePath<>'C:\\Windows\\explorer.exe'" call Terminate
功能:杀死除C:\Windows\explorer.exe以外的所有explorer.exe进程
作者: fengzi     时间: 2008-5-17 15:17
感谢fastslz
不过我并不是想干掉多余的进程``而是想把所有出现这种症状的电脑找出来`
就如同
tasklist |findstr /s /c:"ctfmon.exe" && echo 发现这台电脑有病毒,最后发现时间:%time%>>\\192.168.1.6\log\%computername%.ini ||exit
关键是现在两个同名进程``不知道怎么判断数量`
作者: fastslz     时间: 2008-5-17 15:20
补充
打印除C:\Windows\explorer.exe以外的所有explorer.exe进程
Wmic Process Where "Name='explorer.exe' And ExecutablePath<>'C:\\Windows\\explorer.exe'" Get ExecutablePath

作者: HAT     时间: 2008-5-17 15:22

@echo off
setlocal enabledelayedexpansion
set count=
for /f "tokens=1 delims=:" %%a in ('tasklist ^| findstr /n /i "explorer.exe"') do (
  set /a count=!count!+1
)
echo 有%count%个explorer.exe进程

作者: fengzi     时间: 2008-5-17 15:25
对fastslz的帮助非常感谢`
但是代码是需要在客户机开机运行的时候调用`
用Wmic命令还会提示安装Wmic  而且运行结果没有成功`

我只是想求得一简单判断进程数量的代码``麻烦fastslz再帮我想想`谢谢了`呵呵`
作者: slore     时间: 2008-5-17 15:27
@echo off
for /f %%i in ('tasklist /nh^|findstr /i /s /c:"ctfmon.exe"') do set /a n+=1
echo %n%
pause>nul
作者: fengzi     时间: 2008-5-17 15:27


  Quote:
Originally posted by HAT at 2008-5-17 03:22 PM:
[CODE]@echo off
setlocal enabledelayedexpansion
set count=
for /f "tokens=1 delims=:" %%a in ('tasklist ^| findstr /n /i "explorer.exe"') do (
  set /a count=!count!+1
)
e ...

感谢HAT
好久没有上论坛``这里的高手还是这么热心``
感动ing````
作者: slore     时间: 2008-5-17 15:27
不需要启动变量延迟
作者: fengzi     时间: 2008-5-17 15:30


  Quote:
Originally posted by slore at 2008-5-17 03:27 PM:
不需要启动变量延迟

谢谢``代码很合适`
作者: fastslz     时间: 2008-5-17 15:42

@echo off
for /f "skip=1 delims=*" %%i in ('Wmic Process Where "Name='explorer.exe' And ExecutablePath<>'C:\\Windows\\explorer.exe'" Get ExecutablePath') do (
echo 除C:\Windows\explorer.exe以外的进程路径%%i
set /a count+=1
)
echo 除C:\Windows\explorer.exe以外的总进程数%count%
pause
运行不成功请不要使用精简版系统
作者: fengzi     时间: 2008-5-17 15:45
系统并没有精简
运行结果
无可用范例。
除C:\Windows\explorer.exe以外的总进程数

不过还是非常感谢你的热心帮助`

[ Last edited by fengzi on 2008-5-17 at 03:53 PM ]
作者: fengzi     时间: 2008-5-17 15:53
SORRY 是我粗心了``
作者: pusofalse     时间: 2008-5-17 15:58
for /f "delims=:" %%a in ('^(tasklist^|findstr /i "explorer"^)^|findstr /n .*') do set var=%%a
echo %var%个explorer.exe进程~

[ Last edited by pusofalse on 2008-5-17 at 04:00 PM ]