Hack Forums
[Shell] Simple Taskmanger with Taskkill-function - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Shell] Simple Taskmanger with Taskkill-function (/showthread.php?tid=5818299)



Simple Taskmanger with Taskkill-function - 1337LnD - Mar 30, 2018

Hey guys,

I just created a simple Taskmanager. It lists all active tasks and you are able to kill a task by writing it's name.
I hope that the source will be helpful for people who want to learn more about batch-programming.

Here's the code. Simply copy it into a textfile and save it as .bat
Code
@echo off
set ver=1.0
title Taskmanager %ver%

cls
del tasklist.txt
del temp.txt
for /f %%x in ('tasklist /fi "status eq running"') do echo %%x >> tasklist.txt
sort tasklist.txt > temp.txt
cls
echo ------ Taskmanager %ver% ------
echo by 1337LnD for Hackforums.net
echo.
echo Runnings Tasks
type temp.txt
echo ------------------------------------------------------
echo           The running tasks are listed above
echo.
echo           If you want to kill a task, please write it's name
echo           If you just want to quit, write "exit"
:Action
set /p taskkill="Taskname: "
:Kill
if "%taskkill%"=="exit" goto Exit
tasklist /fi "imagename eq %taskkill%" |find ":" > nul
if errorlevel = 1 (
taskkill /im %taskkill%
echo "%taskkill%" was sucessfully killed!
echo.
echo           If you want to kill another task, please write it's name
echo           Otherwise just write just "exit"
set /p taskkill="Taskname: "
goto Kill
) else (
if errorlevel = 0 echo           Error! The Task "%taskkill%" was not found. Try again.
goto Action
)
:Exit
del tasklist.txt
del temp.txt
exit

Enjoy!  🤝


RE: Simple Taskmanger with Taskkill-function - Sir-Teabag - Mar 31, 2018

I'm just getting continuous errors when I attempt to run it? I read through the script but couldn't find where the problem was though.

[Image: 77732e31aaf14338324011809d6171f1.png]


RE: Simple Taskmanger with Taskkill-function - Phlox - Mar 31, 2018

[Image: kwhosZp.png]

I have modified your batch script and now it works.

Code
@echo off
set ver=1.0
title Taskmanager %ver%

Cls
for /f "Tokens=*" %%x in ('tasklist /fi "status eq running"') do @Echo %%x    

echo.
echo.
echo ------ Taskmanager %ver% ------
echo by 1337LnD for Hackforums.net
echo.
echo Runnings Tasks

echo ------------------------------------------------------
echo           The running tasks are listed above
echo.
echo           If you want to kill a task, please write it's name
echo           If you just want to quit, write "exit"
:Action
set /p taskkill="Taskname: "
:Kill
if "%taskkill%"=="exit" goto Exit
tasklist /fi "imagename eq %taskkill%" |find ":" > nul
if errorlevel = 1 (
taskkill /im %taskkill%
echo "%taskkill%" was sucessfully killed!
echo.
echo           If you want to kill another task, please write it's name
echo           Otherwise just write just "exit"
set /p taskkill="Taskname: "
goto Kill
) else (
if errorlevel = 0 echo           Error! The Task "%taskkill%" was not found. Try again.
goto Action
)
:Exit

exit



RE: Simple Taskmanger with Taskkill-function - Sir-Teabag - Mar 31, 2018

(Mar 31, 2018 07:47 AM)Phlox Wrote:  [Image: kwhosZp.png]

I have modified your batch script and now it works.

Code
@echo off
set ver=1.0
title Taskmanager %ver%

Cls
for /f "Tokens=*" %%x in ('tasklist /fi "status eq running"') do @Echo %%x    

echo.
echo.
echo ------ Taskmanager %ver% ------
echo by 1337LnD for Hackforums.net
echo.
echo Runnings Tasks

echo ------------------------------------------------------
echo           The running tasks are listed above
echo.
echo           If you want to kill a task, please write it's name
echo           If you just want to quit, write "exit"
:Action
set /p taskkill="Taskname: "
:Kill
if "%taskkill%"=="exit" goto Exit
tasklist /fi "imagename eq %taskkill%" |find ":" > nul
if errorlevel = 1 (
taskkill /im %taskkill%
echo "%taskkill%" was sucessfully killed!
echo.
echo           If you want to kill another task, please write it's name
echo           Otherwise just write just "exit"
set /p taskkill="Taskname: "
goto Kill
) else (
if errorlevel = 0 echo           Error! The Task "%taskkill%" was not found. Try again.
goto Action
)
:Exit

exit

which version of windows are you using? I'm just getting a blank terminal
https://gyazo.com/e5a1c12420b16dc7f682db7f74447ead


RE: Simple Taskmanger with Taskkill-function - Phlox - Apr 1, 2018

Windows 10 Pro 64-bit.

[Image: 2sN5j3W.png]


RE: Simple Taskmanger with Taskkill-function - 1337LnD - Apr 2, 2018

I'm using Windows 7 64-bit and it is working fine. I haven't tested it on other machines.