China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-06 10:31
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to automatically detect a process View 1,202 Replies 8
Original Poster Posted 2007-07-08 07:33 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 26
Posts 11
Joined 2007-05-09 18:13
19-year member
UID 87982
Gender Male
Status Offline
Guys, please help me write a batch file or VB script.
I want it so that as soon as it fails to detect a process, for example, as soon as it fails to detect the QQ.exe process, it will immediately reboot the computer. I don't know if any of you guys have a way to help me get this done.
Floor 2 Posted 2007-07-08 08:38 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 26
Posts 11
Joined 2007-05-09 18:13
19-year member
UID 87982
Gender Male
Status Offline
Could it be that nobody will help me? *crying*~
Floor 3 Posted 2007-07-08 15:45 ·  中国 浙江 温州 电信
中级用户
★★
Credits 458
Posts 196
Joined 2006-10-05 12:04
19-year member
UID 64614
Status Offline
Floor 4 Posted 2007-07-08 17:44 ·  中国 湖北 武汉 电信
初级用户
小子
Credits 76
Posts 26
Joined 2007-06-20 19:30
19-year member
UID 91913
Gender Male
Status Offline
@echo off
@echo tasklist^|find /i "QQ.exe"^|^|shutdown -r -t 30>c:\bb.bat
@schtasks /create /sc minute /mo 30 /tn "findQQ" /tr c:\bb.bat /ru ""
@net start schedule

The idea in the second line borrows from brother zerocq.
The purpose of the third line is to add it to Scheduled Tasks, to run once every half hour,
what comes after /tn is the task name
what comes after /tr is the program path
/ru "" means to run under the System account

[ Last edited by tclgb on 2007-7-9 at 10:35 PM ]
Floor 5 Posted 2007-07-08 23:04 ·  中国 广东 佛山 电信
高级用户
★★
我思故我在
Credits 512
Posts 228
Joined 2007-01-21 10:31
19-year member
UID 77225
Gender Male
Status Offline
Actually there's no need to specify the QQ path

@echo off
echo wmic process where name="QQ.exe" call terminate >c:\bb.bat
schtasks /create /sc minute /mo 30 /tn "findQQ" /tr c:\bb.bat /ru ""

[ Last edited by qinbuer on 2007-7-8 at 11:05 PM ]
我确实是只菜鸟,而且这里X人太多,所以我不敢装X。谁要再说我装X,我就XXOO他。
Floor 6 Posted 2007-07-09 19:54 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 26
Posts 11
Joined 2007-05-09 18:13
19-year member
UID 87982
Gender Male
Status Offline
Guys, it doesn't seem to work. Can you help take another look?
Floor 7 Posted 2007-07-09 19:55 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 26
Posts 11
Joined 2007-05-09 18:13
19-year member
UID 87982
Gender Male
Status Offline
Brother, it doesn't seem to work. Can you help me take a look?
Floor 8 Posted 2007-07-09 20:05 ·  中国 广东 佛山 电信
高级用户
★★
我思故我在
Credits 512
Posts 228
Joined 2007-01-21 10:31
19-year member
UID 77225
Gender Male
Status Offline
If the Task Scheduler service isn't running, then although the task can be created, it still can't run. You can

run services.msc and check whether the Task Scheduler service has started.
我确实是只菜鸟,而且这里X人太多,所以我不敢装X。谁要再说我装X,我就XXOO他。
Floor 9 Posted 2007-11-07 12:43 ·  中国 北京 鹏博士BGP
初级用户
Credits 44
Posts 25
Joined 2007-03-10 08:07
19-year member
UID 81294
Gender Male
Status Offline
Thanks, I just happened to be testing a script like this.
Forum Jump: