|
computer425
新手上路

积分 18
发帖 8
注册 2007-6-21
状态 离线
|
『楼 主』:
[求助]如何实现每30秒检测一次进程并运行指定的命令?
使用 LLM 解释/回答一下
我需要做到每30秒检测一个进程的运行,如果不存在电脑重启,并且这个批处理每30秒自己运行检测。
:loop
tasklist|findstr /i "explorer.exe" ||shutdown -s -t 50
ping 127.1 -n 600 >nul 2>nul
goto loop
我看前面帖子是这么写的,但是我运用是一定要自己点这个批处理才能起作用,我希望是这个批处理能每30秒自己做到运行。
我也看了很多大家写的这方面帖子,但是我运用起来感觉起不了作用,我是个门外汉,对批处理不懂,希望大家能写个完整的批处理,让我学习下。谢谢!
─────────────────── 版务记录 ────────────────────
执行:lxmxn
说明:因在提示修改标题之后3日内未修改标题,扣除2点积分,并由本人修改标题。
─────────────────── 版务记录 ────────────────────
Last edited by lxmxn on 2007-6-24 at 11:45 PM ]
I need to detect the running of a process every 30 seconds. If it doesn't exist, the computer restarts, and this batch processing runs the detection every 30 seconds.
:loop
tasklist|findstr /i "explorer.exe" ||shutdown -s -t 50
ping 127.1 -n 600 >nul 2>nul
goto loop
I saw this written in the previous post, but when I use it, it must be clicked on this batch processing to work. I hope this batch processing can run by itself every 30 seconds.
I have also read many posts written by everyone in this regard, but when I use it, it doesn't seem to work. I'm a layman and don't understand batch processing. I hope everyone can write a complete batch processing for me to learn. Thank you!
─────────────────── Moderation Record ────────────────────
Performed by: lxmxn
Description: Because the title was not modified within 3 days after being prompted to modify the title, 2 points were deducted, and the title was modified by myself.
─────────────────── Moderation Record ────────────────────
Last edited by lxmxn on 2007-6-24 at 11:45 PM ]
此帖被 -2 点积分 点击查看详情 评分人:【 lxmxn 】 | 分数: -2 | 时间:2007-6-24 23:38 |
|
|
|
2007-6-21 10:34 |
|
|
zasxcdfv
初级用户
 
积分 152
发帖 75
注册 2007-2-6
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
晕,这个程序不太好把
@echo off
tasklist >> tasklisttmp.txt
findstr /i "你要监视的进程名" tasklisttmp.txt >nul
if errorlevel 1 (del tasklisttmp.txt&shutdown -r -f) else del tasklisttmp.txt
ping -n 30 127.0.0.1 > nul
call %0
没有测试shutdown -r……改成del tasklisttmp.txt&echo yes!!! 测试成功.....
期待高人指教~
Last edited by zasxcdfv on 2007-6-21 at 10:48 AM ]
Oh, this program isn't very good.
@echo off
tasklist >> tasklisttmp.txt
findstr /i "the process name you want to monitor" tasklisttmp.txt >nul
if errorlevel 1 (del tasklisttmp.txt&shutdown -r -f) else del tasklisttmp.txt
ping -n 30 127.0.0.1 > nul
call %0
Didn't test shutdown -r... Changed to del tasklisttmp.txt&echo yes!!! Test succeeded.....
Looking forward to experts' guidance~
Last edited by zasxcdfv on 2007-6-21 at 10:48 AM ]
|
|
2007-6-21 10:37 |
|
|
lotus516
高级用户
    论坛上抢劫的
积分 551
发帖 246
注册 2006-9-21
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
lz把它放到开机启动不就可以了吗?还有600改为30!!
Why not put it in the startup at boot? Also, change 600 to 30!!
|
|
2007-6-22 14:14 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
try this one :)
@echo off
rem 重启应该使用-r
tasklist|findstr /i "explorer.exe" ||shutdown -r -t 50
rem willsort斑竹说过,第一条消息是不需要等待的,所以延时30秒,应该用-n 31
ping 127.1 -n 31 >nul 2>nul
rem 不必使用循环,call一下自己就行了
call %0
try this one :)
@echo off
rem Should use -r to restart
tasklist|findstr /i "explorer.exe" ||shutdown -r -t 50
rem Moderator willsort said that the first message does not need to wait, so delay for 30 seconds, should use -n 31
ping 127.1 -n 31 >nul 2>nul
rem No need to use a loop, just call itself
call %0
|
|
2007-6-22 17:34 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
vbs写还差不多。。
批处理会死人的。
VBS is almost okay..
Batch processing will kill people.
|

知,不觉多。不知,乃求知 |
|
2007-6-22 23:42 |
|
|
joshualaw
初级用户
 
积分 132
发帖 62
注册 2007-6-5
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Originally posted by flyinspace at 2007-6-22 11:42 PM:
vbs写还差不多。。
批处理会死人的。
能否用VBS写一个,来实现这一功能( 只要电脑每次一启动,每隔30秒自动去调用和运行某一P处理)
高手们, 能实现吗,请出招啊
Last edited by joshualaw on 2007-6-24 at 09:37 PM ]
Originally posted by flyinspace at 2007-6-22 11:42 PM:
It's better to write with VBS.
Batch processing will drive people crazy.
Can a VBS be written to achieve this function ( As long as the computer starts up each time, it automatically calls and runs a certain P process every 30 seconds)
Experts, can it be achieved, please come up with a move啊
Last edited by joshualaw on 2007-6-24 at 09:37 PM ]
|
|
2007-6-24 21:28 |
|
|
zasxcdfv
初级用户
 
积分 152
发帖 75
注册 2007-2-6
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
Originally posted by HAT at 2007-6-22 05:34 PM:
tasklist|findstr /i "explorer.exe" ||shutdown -r -t 50
rem willsort斑竹说过,第一条消息是不需要等待的,所以延时30秒,应该用-n 31
受教了!
之前好像有通过将程序定义为服务的方式自启动的帖子
lz可以翻翻
Last edited by zasxcdfv on 2007-6-25 at 11:14 AM ]
Originally posted by HAT at 2007-6-22 05:34 PM:
tasklist|findstr /i "explorer.exe" ||shutdown -r -t 50
rem Bamboo Master willsort said that the first message does not need to wait, so the delay is 30 seconds, it should be -n 31
Got it!
There seemed to be a post before about starting a program automatically by defining it as a service.
LZ can flip through it
Last edited by zasxcdfv on 2007-6-25 at 11:14 AM ]
|
|
2007-6-25 11:11 |
|
|
joshualaw
初级用户
 
积分 132
发帖 62
注册 2007-6-5
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Originally posted by zasxcdfv at 2007-6-25 11:11 AM:
受教了!
之前好像有通过将程序定义为服务的方式自启动的帖子
lz可以翻翻
Last edited by zasxcdfv on 2007-6-25 at 11:14 AM ]
能否把那帖子连接到这呢
Originally posted by zasxcdfv at 2007-6-25 11:11 AM:
Got it!
There seemed to be a previous post about starting a program automatically by defining it as a service.
LZ can look it up.
Last edited by zasxcdfv on 2007-6-25 at 11:14 AM ]
Can you link that post here?
|
|
2007-6-26 21:31 |
|
|
lasting
初级用户
 
积分 52
发帖 24
注册 2007-5-9
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
可以用延时来解决。。不过想要等30秒后再运行就要等高手来处理了。。
延时方法
:loop
tasklist|findstr /i "explorer.exe" ||shutdown -s -t 50
setlocal enableextensions
echo WScript.Sleep 30000> %temp%.\tmp$$$.vbs ;这里的30000是毫秒。1000毫秒=1秒。你想延时多久自己算。
@cscript //nologo %temp%.\tmp$$$.vbs
goto loop
这个简单 一个VB延时就OK
再来一个自动生成文件
echo q | debug>nul
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>sleep.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>sleep.com
echo T}{z~~@GwkBG@OEKcUt`~}@MqqBsy?seHB~_Phxr?@zAB`LrPEyoDt@Cj?>>sleep.com
echo pky_jN@QEKpEt@ij?jySjN@REKpEt@jj?jyGjN@SEKkjtlGuNw?p@pjirz>>sleep.com
echo LFvAURQ?OYLTQ@@?~QCoOL~RDU@?aU?@{QOq?@}IKuNWpe~FpeQFwH?Vkk>>sleep.com
echo _GSqoCvH{OjeOSeIQRmA@KnEFB?p??mcjNne~B?M??QhetLBgBPHexh@e=>>sleep.com
echo EsOgwTLbLK?sFU`?LDOD@@K@xO?SUudA?_FKJ@N?KD@?UA??O}HCQOQ??R>>sleep.com
echo _OQOL?CLA?CEU?_FU?UAQ?UBD?LOC?ORO?UOL?UOD?OOI?UgL?LOR@YUO?>>sleep.com
echo dsmSQswDOR
It can be solved with delay... But if you want to run it after waiting 30 seconds, you need to wait for an expert to handle it..
Delay method
:loop
tasklist|findstr /i "explorer.exe" ||shutdown -s -t 50
setlocal enableextensions
echo WScript.Sleep 30000> %temp%.\tmp$$$.vbs ;Here 30000 is milliseconds. 1000 milliseconds = 1 second. Calculate how long you want to delay by yourself.
@cscript //nologo %temp%.\tmp$$$.vbs
goto loop
This is simple. Just a VB delay is OK
Here's another one to generate a file automatically
echo q | debug>nul
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>sleep.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>sleep.com
echo T}{z~~@GwkBG@OEKcUt`~}@MqqBsy?seHB~_Phxr?@zAB`LrPEyoDt@Cj?>>sleep.com
echo pky_jN@QEKpEt@ij?jySjN@REKpEt@jj?jyGjN@SEKkjtlGuNw?p@pjirz>>sleep.com
echo LFvAURQ?OYLTQ@@?~QCoOL~RDU@?aU?@{QOq?@}IKuNWpe~FpeQFwH?Vkk>>sleep.com
echo _GSqoCvH{OjeOSeIQRmA@KnEFB?p??mcjNne~B?M??QhetLBgBPHexh@e=>>sleep.com
echo EsOgwTLbLK?sFU`?LDOD@@K@xO?SUudA?_FKJ@N?KD@?UA??O}HCQOQ??R>>sleep.com
echo _OQOL?CLA?CEU?_FU?UAQ?UBD?LOC?ORO?UOL?UOD?OOI?UgL?LOR@YUO?>>sleep.com
echo dsmSQswDOR
|
|
2007-6-26 22:03 |
|
|
joshualaw
初级用户
 
积分 132
发帖 62
注册 2007-6-5
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
Originally posted by lasting at 2007-6-26 10:03 PM:
可以用延时来解决。。不过想要等30秒后再运行就要等高手来处理了。。
延时方法
这个简单 一个VB延时就OK
再来一个自动生成文件
我试了一下,好象还是不能实现哦,上面的P处理是不是能每隔30秒能自动的去运行某一P 处理啊 (假设 C:\123.bat),类似“任务管理器”啊,而不要人去double click.
Originally posted by lasting at 2007-6-26 10:03 PM:
Delay can be used to solve it. But if you want to run it after 30 seconds, you need to wait for experts to handle it..
Delay method
This is simple. A VB delay will do.
Then another one to automatically generate a file
I tried it, but it still doesn't seem to work. Does the above P processing can automatically run a certain P processing every 30 seconds (assuming C:\123.bat), similar to "Task Manager", without having to double click.
|
|
2007-6-27 23:47 |
|
|
lasting
初级用户
 
积分 52
发帖 24
注册 2007-5-9
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
晕。。你想30秒后自动运行。。添加计划任务吧。
Oh, come on. You want to run it automatically after 30 seconds. Add a scheduled task.
|
|
2007-6-28 10:17 |
|
|
bob1989
中级用户
  
积分 322
发帖 144
注册 2007-1-10
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
计划任务里面怎么加??没有这种任务把
How to add it in the task scheduler?? There is no such task, right
|
|
2007-6-28 11:09 |
|
|
joshualaw
初级用户
 
积分 132
发帖 62
注册 2007-6-5
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
想用一个自动的方式,不想用计划任务,能做的到吗
Want to use an automatic way, don't want to use task scheduler, can it be done?
|
|
2007-6-28 15:31 |
|