中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-05 06:31
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » [Help] How to detect a process every 30 seconds and run a specified command?
Printable Version  2,029 / 12
Floor1 computer425 Posted 2007-06-21 10:34
新手上路 Posts 8 Credits 18
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 ]
Floor2 zasxcdfv Posted 2007-06-21 10:37
初级用户 Posts 75 Credits 152
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 ]
Floor3 lotus516 Posted 2007-06-22 14:14
高级用户 Posts 246 Credits 551
Why not put it in the startup at boot? Also, change 600 to 30!!
Floor4 HAT Posted 2007-06-22 17:34
版主 Posts 5,017 Credits 9,023
try this one :)
Floor5 flyinspace Posted 2007-06-22 23:42
银牌会员 Posts 517 Credits 1,206
VBS is almost okay..
Batch processing will kill people.
Floor6 joshualaw Posted 2007-06-24 21:28
初级用户 Posts 62 Credits 132
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 ]
Floor7 zasxcdfv Posted 2007-06-25 11:11
初级用户 Posts 75 Credits 152
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 ]
Floor8 joshualaw Posted 2007-06-26 21:31
初级用户 Posts 62 Credits 132
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?
Floor9 lasting Posted 2007-06-26 22:03
初级用户 Posts 24 Credits 52
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













Floor10 joshualaw Posted 2007-06-27 23:47
初级用户 Posts 62 Credits 132
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.
Floor11 lasting Posted 2007-06-28 10:17
初级用户 Posts 24 Credits 52
Oh, come on. You want to run it automatically after 30 seconds. Add a scheduled task.
Floor12 bob1989 Posted 2007-06-28 11:09
中级用户 Posts 144 Credits 322
How to add it in the task scheduler?? There is no such task, right
Floor13 joshualaw Posted 2007-06-28 15:31
初级用户 Posts 62 Credits 132
Want to use an automatic way, don't want to use task scheduler, can it be done?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023