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-06-24 05:12
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to end one of two processes with the same name using batch processing View 1,583 Replies 10
Original Poster Posted 2007-07-02 17:56 ·  中国 北京 鹏博士BGP
初级用户
Credits 126
Posts 47
Joined 2007-07-02 17:00
18-year member
UID 92952
Gender Male
Status Offline
The system here uses a software that shields keywords in Explorer.exe to restrict downloads. But if you use taskkill /f /im Explorer.exe, it will end the desktop process explorer.exe together. I want to ask if there is any way to only end the keyword process Explorer.exe without ending the desktop process explorer.exe? I don't want to first use tasklist to find the PID value of Explorer.exe each time.
Floor 2 Posted 2007-07-02 22:21 ·  中国 山东 聊城 电信
系统支持
★★★
Credits 1,010
Posts 434
Joined 2007-02-08 00:00
19-year member
UID 78999
Gender Male
Status Offline
Floor 3 Posted 2007-07-02 22:53 ·  中国 广东 佛山 电信
高级用户
★★
我思故我在
Credits 512
Posts 228
Joined 2007-01-21 10:31
19-year member
UID 77225
Gender Male
Status Offline
PID cannot directly distinguish between two EXPLORERs. It is just randomly assigned by the system when the process runs and does not represent a specific process. So simply looking at the PID, you won't know which EXPLORER you should terminate. But we can analyze the paths of the two processes through WMIC. As long as it is an EXPLORER not under C:\WINDOWS, terminate the PID of that process.

[ Last edited by qinbuer on 2007-7-3 at 12:04 PM ]
我确实是只菜鸟,而且这里X人太多,所以我不敢装X。谁要再说我装X,我就XXOO他。
Floor 4 Posted 2007-07-03 08:11 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
First, taskkill /f /im explorer.exe, then start %systemroot%\explorer.exe. Or as the brother upstairs said, check the path of the program to judge.
Floor 5 Posted 2007-07-03 23:58 ·  中国 北京 鹏博士BGP
初级用户
Credits 126
Posts 47
Joined 2007-07-02 17:00
18-year member
UID 92952
Gender Male
Status Offline
I'm surfing in an internet cafe.
If I use taskkill /f /im Explorer.exe, it will end the system's desktop process explorer.exe together. Reloading explorer will cause the icon of the billing system in the system tray to be invisible and unable to check out.
Of course, I might first use tasklist to find the PID value of the Explorer.exe process (here, the difference between the system process and the keyword blocking process name is that the system process is all lowercase, and the first letter of the keyword blocking process is uppercase, so I can clearly judge which one is the one to end), and then use taskkill /f /pid +PID value to end it.
But because the system has made a lot of restrictions, I find it tedious to check like this every time.
I want to ask if it is possible to first use tasklist to list the process information, then use the find function to find the PID value of the keyword process, and then use taskkill to end the process by calling the found value?
Floor 6 Posted 2008-01-22 19:18 ·  中国 广东 深圳 电信
初级用户
★★
Credits 135
Posts 64
Joined 2006-12-20 04:35
19-year member
UID 74003
Gender Male
Status Offline
I have a simpler question. If I find there are two explorer.exe, then execute a command saying that this machine is infected with a virus. How should I write it???

Brother LX, please help me!!!
Floor 7 Posted 2008-01-22 19:19 ·  中国 广东 深圳 电信
初级用户
★★
Credits 135
Posts 64
Joined 2006-12-20 04:35
19-year member
UID 74003
Gender Male
Status Offline
I thought about using whether the PIDs are equal to determine whether this machine has two explorer.exe. If there is one, then they must be equal; if there are two, they must be not equal. But how to judge equality?
Floor 8 Posted 2008-01-22 19:31 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
tasklist /FI "IMAGENAME eq explorer.exe"
The system is case-insensitive...
So you will get 2. Then you can do a findstr on it (this is case-sensitive)

Then do what you want to do by yourself... Oh, by the way, you can get the PID from the above
Floor 9 Posted 2008-01-22 19:55 ·  中国 江苏 常州 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
20-year member
UID 42345
Status Offline
Try this way

@echo off
for /f "tokens=1,2" %%i in ('tasklist /nh /FO TABLE') do (
if "%%i" == "Explorer.exe" taskkill /FI "pid eq %%j"
)
pause


taskkill /FI "pid eq %%j" may need to add /f

[ Last edited by terse on 2008-1-22 at 08:02 PM ]
简单!简单!再简单!
Floor 10 Posted 2008-01-22 22:26 ·  中国 广东 深圳 电信
初级用户
★★
Credits 135
Posts 64
Joined 2006-12-20 04:35
19-year member
UID 74003
Gender Male
Status Offline
Has everyone seen my question??

My question is, if I find there are two explorer.exe, then send a message to the server saying that this computer may be infected with a virus. How to do it??? I'm a big newbie. I don't know anything!!
Floor 11 Posted 2008-01-24 17:04 ·  中国 广西 南宁 电信
新手上路
Credits 2
Posts 1
Joined 2008-01-24 16:13
18-year member
UID 109432
Gender Male
Status Offline
Thanks to the script from floor 9, my script for hiding the process of a specified program has made progress
Forum Jump: