无忧启动论坛

标题: 批处理进程监视 [打印本页]

作者: YOBOOT    时间: 2015-9-3 09:51
标题: 批处理进程监视
批处理代号“M”,查找test.exe.找不到结束M进程,找到并运行,当test.exe运行直到自动关闭(test.exe进程自动kill itself),结束批处理M进程.


“M”命令:

@echo off
set "str=test.exe"
set "drv=c d e f g h i j k l m n o p q r s t u v w x y z"
for %%a in (%drv%) do (
if exist %%a: (
for /f "delims=" %%b in ('dir /s/b/a-d "%%a:\%str%" 2^>nul') do (
if not "%%b"=="" (
start "" "%%b"
exit
)
)
)
)

问题是 M 缺少监视test.exe的进程命令,怎么监视?

作者: nttwqz    时间: 2015-9-3 17:08
不明白楼主什么意思,是要监视test.exe是否运行,还是监视其文件读写记录、注册表读写记录、联网记录?
作者: YOBOOT    时间: 2015-9-3 18:29
本帖最后由 YOBOOT 于 2015-9-3 18:39 编辑
nttwqz 发表于 2015-9-3 17:08
不明白楼主什么意思,是要监视test.exe是否运行,还是监视其文件读写记录、注册表读写记录、联网记录?


批处理命令“M” 寻找A.exe并运行
---------------------------------------------
找不到A.exe,结束命令“M”并回显“提示001”
找得到A.exe,运行A.exe .当A.exe(进程A.exe)自己运行结束 结束命令“M”
作者: wjgyz740526    时间: 2015-9-3 20:35
用tasklist列进程然后findstr关键字就可以了
作者: nttwqz    时间: 2015-9-3 23:19
YOBOOT 发表于 2015-9-3 18:29
批处理命令“M” 寻找A.exe并运行
---------------------------------------------
找不到A.exe,结束 ...


你有能力在for中嵌套for,应该也知道start有个/wait参数,start /wait notepad.exe,启动记事本直到其退出。




欢迎光临 无忧启动论坛 (http://wuyou.net/) Powered by Discuz! X3.3