进程监控小脚本

作者: admin 分类: 未分类 发布时间: 2016-12-27 16:42

新添加功能:
每秒刷新监控指定进程 r参数

@echo off
    setlocal EnableDelayedExpansion
    set process=%1
    set Refresh=%2
    ::code by lostwolf
    ::如果不存在 打印帮助信息
    if not defined process (
    echo The syntax of the command is incorrect.
    echo.
    echo Help:
    echo       %~n0 ProcessName
    echo.
    echo example:
    echo       %~n0  svchost
    echo       %~n0  all
    echo       %~n0  ProcessName r
    goto :EOF
    )

    if %process% ==all (
    wmic process list brief
    goto :EOF
    )
if not defined Refresh (
wmic process where "((commandline like '%%!process!%%' or (name like '%%!process!%%'))  AND NOT (commandline like '%%_wmic_%%'))" get ProcessId,name,commandline
goto :EOF
)
wmic process where "((name like '%%!process!%%')  AND NOT (commandline like '%%_wmic_%%'))" get  ProcessId,name,commandline /every:1
标签云