![]() |
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-09 14:18 |
47,811 topics / 349,895 posts / today 0 new / 48,254 members |
| DOS批处理 & 脚本技术(批处理室) » How to obtain the PID of a process and force kill it |
| Printable Version 3,465 / 21 |
| Floor1 lxsky | Posted 2007-03-29 12:50 |
| 新手上路 Posts 4 Credits 14 | |
|
Now the computer is infected with a virus, and the process is abc.exe. Directly using tskill can't kill it at all, but using ntsd -c q -p PID to end the process works. Now I want to implement it with a batch script. I'm a newbie. I read many forum posts and still feel not very good.
@echo off for /f "tokens=1,2" %%i in ('tasklist') do ( echo %%i | findstr /i "abc.exe" 1>nul 2>nul && ( ntsd -c q -p %%j & set qq=%%i ) ) if /i not "%qq%"=="abc.exe" echo No virus echo. pause It works under XP, not sure if it works under 2000? There's one in the forum: tasklist | findstr "abc.exe"&&goto :p It's also okay to wrap it, not sure how to do it. Everyone help simplify it, I also want to learn. |
|
| Floor2 baomaboy | Posted 2007-03-29 13:45 |
| 银牌会员 Posts 554 Credits 1,513 | |
Originally posted by lxsky at 2007-3-29 12:50: Why do you have to use PID specifically? Can't you just use ntsd -c q -pn abc.exe? |
|
| Floor3 lxsky | Posted 2007-03-29 23:50 |
| 新手上路 Posts 4 Credits 14 | |
|
Hehe, thanks to the 2nd floor, ntsd can indeed be used like this
|
|
| Floor4 lp1129 | Posted 2007-03-30 11:52 |
| 初级用户 Posts 92 Credits 186 | |
|
This is a relatively powerful command,
Taskkill /IM /F abc.exe If someone says something like only XP machines can use it, then buddy, your machine really needs to be eliminated! |
|
| Floor5 axi | Posted 2007-03-30 12:07 |
| 中级用户 Posts 93 Credits 238 From GZ | |
Originally posted by lp1129 at 2007-3-29 22:52: Correct! On XP, you can use taskkill. If you use: taskkill /f /t /im abc.exe it's even more powerful, killing its child processes at the same time. |
|
| Floor6 everest79 | Posted 2007-03-30 12:35 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
If you refuse external termination, taskkill won't work either. Try using kaspersky.
|
|
| Floor7 lxmxn | Posted 2007-04-02 00:21 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Just to interject, the command format on the 4th floor is incorrect. |
|
| Floor8 flyinspace | Posted 2007-04-02 00:38 |
| 银牌会员 Posts 517 Credits 1,206 | |
Originally posted by lp1129 at 2007-3-29 10:52 PM: I still, need to consider universality when writing a command. If it is not supported, then disable your own script on the machine of that object. Moreover, in China now, many enterprises still use Windows 2000. |
|
| Floor9 slore | Posted 2007-04-02 00:54 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
Taskkill.exe copy it over and use it to see
|
|
| Floor10 axi | Posted 2007-04-04 01:25 |
| 中级用户 Posts 93 Credits 238 From GZ | |
|
I remember there is a file inject.dll on the Internet for terminating processes. The usage is (first copy inject.dll to the system32 directory):
rundll32 inject.dll,Install explorer.exe vnetclient.exe qqgame.exe... After running, it kills the processes vnetclient.exe, QQGame.exe... every 1 second, which can prevent the related processes from starting. This program will generate this file %windir%\system32\BlackList.config after running. You can edit its content with Notepad to add or delete processes. Installation: @echo off if exist %windir%\system32\inject.dll goto BlackList copy /y inject.dll %windir%\system32\ >nul if not exist %windir%\system32\inject.dll exit rundll32 inject.dll,Install explorer.exe vnetclient.exe :BlackList notepad.exe %windir%\system32\BlackList.config|taskkill /f /im cmd.exe Uninstallation (please save settings before using): @echo off reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v inject /f taskkill /f /im explorer.exe ping 0 -n 2 >nul start explorer.exe del /f/q %windir%\system32\inject.dll del /f/q %windir%\system32\BlackList.config [ Last edited by axi on 2009-1-23 at 22:46 ] Attachments inject.rar (51.2 KiB) |
|
| Floor11 applecy | Posted 2007-04-04 01:39 |
| 初级用户 Posts 78 Credits 168 | |
|
Just kidding, the most amazing thing is shutting down
|
|
| Floor12 baomaboy | Posted 2007-04-04 02:16 |
| 银牌会员 Posts 554 Credits 1,513 | |
Originally posted by axi at 2007-4-4 01:25: This is interesting. Let's give it a try. |
|
| Floor13 a201341717 | Posted 2007-04-04 02:38 |
| 贫困用户 Posts 20 Credits -2 | |
![]() |
|
| Floor14 everest79 | Posted 2007-04-05 13:20 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
Good stuff of 10f, not sure about resource usage
|
|
| Floor15 axi | Posted 2007-04-05 21:46 |
| 中级用户 Posts 93 Credits 238 From GZ | |
|
Thanks to brother everest97 for the points. This thing occupies very little resources. The following is an explanation about it:
ProcessInjector is a DLL injection-based prank software. It can perform the operation of ending the tasks of programs on the user-defined blacklist. Uses: * Prevent ignorant guys from using IE to download Adware. (Of course, it means only allowing the use of the firefox browser :) ) * Rescue guys lost in online games * Make telecommunication employees who come in to install "Sky Speed" return empty-handed This program takes into account the computer level of the pranked object, and uses the DLL injection technology. There is no physical program; only the DLL is installed into the DLL host process. However, IceSword and Process Explorer can easily detect this program. Usage method: Make sure you copy inject.dll to the %SYSTEM32% directory. Enter in Start -> Run: rundll32 inject.dll,Install <host> Among them, the host is the process name you want to inject (with the.exe extension). The host can be explorer.exe, or it can be system critical processes such as winlogon.exe, smss.exe, conime.exe, etc. Using system critical processes will make it impossible to end the activity of inject.dll. Once the host is killed, ProcessInjector will stop running. The prohibited program list (with the.exe extension) is the program names that will be added to the blacklist, and they will be killed by inject.dll once per second. Note: Each time inject.dll is installed, it will overwrite the content of the original blacklist file. After running this program, a configuration file BlackList.config will be generated, and the "inject" = "rundll32 inject.dll,Install explorer.exe" will be added to the registry startup item. Telecommunication employees will encounter the problem that the main program of Sky Speed "disappears without reason". Example: rundll32 inject.dll,Install explorer.exe vnetclient.exe iexplorer.exe qqgame.exe The program will insert inject.dll into the explorer.exe process, add itself to the system startup item, create the blacklist file %SYSTEM32%\blacklist.config, and kill IE, QQ game, and the main program of Sky Speed all once per second. The program names are case-insensitive. The generated BlackList.config file: vnetclient.exe iexplorer.exe qqgame.exe The blacklist file that can be edited in real time: The blacklist file of ProcessInjector (%SYSTEM32%\BlackList.config) can be edited in real time. ProcessInjector reloads the blacklist once every 10 seconds. You can open the blacklist file with Notepad and add the program names you don't like :) About resource occupancy: Under my test environment (Celeron M 1.4G + 512MB memory), ProcessInjector has a negligible impact on the CPU occupancy of the host. Uninstallation: Go to HKLM\Software\Microsoft\Windows\CurrentVersion\Run to find the inject item and delete it. After restarting, delete %SYSTEM32%\blacklist.config and %SYSTEM32%\inject.dll. (Optional) About this software: This software is free software. Outmatch guarantees with personality that there is no malicious code, however, it does not guarantee that this program will run correctly on your computer. [ Last edited by axi on 2007-4-5 at 08:59 AM ] |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |