中国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-02 20:19
48,038 topics / 350,123 posts / today 1 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » Batch script to close a process
Printable Version  2,479 / 5
Floor1 sjs0512 Posted 2006-12-15 10:42
中级用户 Posts 69 Credits 201
For example, I use tasklist>1.txt, and then I need to find the process with PID 132 in this 1.txt, and then use taskkill /pid to close this process. How to write the batch script?
Mainly I don't know how to find things in 1.txt with batch. Please forgive me.
Can the experts teach me?

[ Last edited by namejm on 2006-12-14 at 10:42 PM ]
Floor2 namejm Posted 2006-12-15 10:53
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Terminate the process with the specified PID. You don't need to first use tasklist and then terminate it; you can directly use taskkill /pid. The demonstration code is as follows:
Floor3 sjs0512 Posted 2006-12-15 11:30
中级用户 Posts 69 Credits 201
Thanks, and another question. How to write a batch script to close the process with PID 132. The requirement is that once the user runs the program with PID 132, it will be automatically closed after 5 seconds
Floor4 sjs0512 Posted 2006-12-15 11:30
中级用户 Posts 69 Credits 201
Then how to change the title?
Floor5 lxmxn Posted 2006-12-15 12:56
版主 Posts 4,938 Credits 11,386
Originally posted by sjs0512 at 2006-12-15 11:30:
Thanks. Another question. How to write a batch script to close the process with PID 132.
Requirement: Once the user runs the program with PID 132, it will be automatically closed after 5 seconds


  Generally, this method is not recommended. This requires the batch script to always monitor the system processes, which will result in relatively high CPU usage.
Floor6 jmz573515 Posted 2006-12-15 20:51
银牌会员 Posts 464 Credits 1,212
You can use VBS to monitor a certain process, and if it is running, kill it. But it needs to be resident in memory.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023