End a process that cannot be ended by a normal method

Posted by Headache on Wed, 01 Jan 2020 03:57:21 +0100

Use NTSD program (if you have installed VS, in the VS installation directory, such as "C: \ program files (x86)," debugging tools for windows (x86), "ntsd.exe", or Download here)

ntsd -c q -p PID
ntsd -c q -pn PName

Two methods

One is to use the ID number of the process and replace the PID with the corresponding process ID number

One is to use the process name and change PName to the corresponding exe name, such as notepad.exe

For convenience, write a batch, put the batch and ntsd together, execute the batch when using, select the corresponding method, and enter the parameters.

@ECHO OFF
TITLE End a process that cannot be ended with normal methods
COLOR 0A
MODE con: COLS=62 LINES=22

:MENU
set tm1=%time:~0,2%
set tm2=%time:~3,2%
set tm3=%time:~6,2%
ECHO.  %date% %tm1%spot%tm2%branch%tm3%second 
ECHO.   ========================================
ECHO.   Select the action you want to do and press enter
ECHO.   ────────────────────
ECHO.  1    According to the process number PID End process
ECHO.  2    End process by process name

ECHO.  0    Sign out
ECHO.
ECHO.Please enter the serial number of the selected item:

set /p choose=
if "%choose%" equ "" goto MENU
if %choose%==1 goto killusingpid
if %choose%==2 goto killusingname
if %choose%==0 goto END

ECHO. Input error, please input correct item No.:
goto MENU

:killusingpid
set choose=
ECHO.Please enter the process number PID,Then press enter
set /p proid=
set /a i=0
:kpid
ntsd -c q -p %proid%
if %i% GEQ 10 ( ( echo End process%proid%fail ) & goto MENU )
set /a i=%i%+1
echo End process%proid%The first%i%second
tasklist | findstr /i %proid% && ( goto kpid )
echo End process ID by%proid%Program success or process for ID:%proid%Non-existent
GOTO MENU

:killusingname
set choose=
ECHO.Please enter the name of the process(such as notepad.exe),Then press enter
set /p proname=
set /a i=0
:kpname
ntsd -c q -pn %proname%
if %i% GEQ 10 ( ( echo End procedure%proname%fail ) & goto Menu )
set /a i=%i%+1
echo End procedure%proname%The first%i%second
tasklist | findstr /i %proname% && goto kpname
echo End procedure%proname%Success or program:%proname%Not started

GOTO MENU

:END
exit

 

 

 

 

Reference resources:

https://docs.microsoft.com/zh-cn/windows-hardware/drivers/debugger/cdb-command-line-options

Topics: Windows