Here is a relatively simple script that is a "helper" for the programs tasklist and
taskkill.
After copying and pasting the text between the lines into a text file and [re]naming
that file TASKZ.BAT
You can then use it in two ways: 1). Interactively. Type TASKZ and the tasklist
(including a list of PIDs) will be displayed. After the task list is displayed, you
are prompted to enter a PID from the above list (use the mouse wheel to scroll up and
down the list to identify the Application / PID you want to terminate). Enter the
chosen PID and press ENTER and the application is terminated.
or 2). Add parameter. If you already know the PID of the app. you want to terminate,
just type TASKZ [pid]
(where [pid] stands for the numerical Process ID)
------------------- copy between lines -------------------
@echo off
SETLOCAL
if %1]==] goto TASKS
if %1]==/?] goto HELP
if %1]==-?] goto HELP
if %1]==?] goto HELP
goto TERMINATE
:HELP
echo.
echo Batch file to help terminate
echo an application by reviewing
echo all apps currently in memory
echo then entering it's PID to
echo terminate.
echo.
echo Or, if the PID is already known
echo enter TASKZ followed by [pid]
echo to terminate the application.
echo.
echo TASKZ [pid]
echo.
echo pid - Numerical App. ID
echo.
echo Type TASKZ to start interactively.
echo.
goto :EOF
:TASKS
echo.
echo A list of tasks and their PIDs
echo will now be shown - then type
echo a PID to terminate that app...
echo.
echo (Tip: Use mousewheel to scroll)
echo.
pause
tasklist
echo.
echo Now enter a PID from the above
echo list to terminate the associated
echo application.
echo.
echo (Use mousewheel to scroll up)
echo.
echo (Just press ENTER to cancel)
echo.
set /p PID=Enter PID=
echo.
if NOT DEFINED PID (goto CANCEL) else (goto TERMINATE)
:TERMINATE
echo.
echo Application ID=%PID%
echo.
echo Terminating...
echo.
taskkill /F /PID %PID%
if ERRORLEVEL 1 goto TK_ERROR
set PID=
goto :EOF
:TK_ERROR
echo.
echo The PID you typed was invalid
echo.
echo You must enter a valid PID number
echo from the list displayed.
echo.
goto :EOF
:CANCEL
echo.
echo Operation cancelled.
echo.
------------------- copy between lines -------------------
==
Cheers, Tim Meddick, Peckham, London. :-)
"joshakame" <joshakame.40ovbc@DoNotSpam.com> wrote in message
news:joshakame.40ovbc@DoNotSpam.com...
>
> I am trying to create a batch file that will give the user a choice of
> the task files he wants to kill. So, for instance if he wants to kill
> PID 456 (just an example) then all he has to type in is the PID, in
> other words all he would have to type in is 456 and press enter. My
> problem is that I can't figure out how to do that.
>
>
> --
> joshakame
> ------------------------------------------------------------------------
> joshakame's Profile: http://forums.techarena.in/members/149027.htm
> View this thread: http://forums.techarena.in/customize-xp/1263522.htm
>
> http://forums.techarena.in
>