Translate

Sunday 31 August 2014

Process sniper - batch file



 
This is a small program I have been working on.  I have been working on it for a few hours in total so it still might have some bugs, but anyway.
The batch file contains two functions, 1.) it will list all the processes that are running on your computer and 2.) it can kill the process that you type in by either name (process.process extension e.g notepad.exe) or PID.  It also outputs all the process names you type in to an external file that is written over when you start the batch file again, the name of this file is configurable in the code under the variables at the top of the code.  It could easily save it anywhere on your hard drive with only very minor tweaks to the code.
here is the code:
 
 
@ECHO OFF
set version=1.6
set outputfile=log
set outfileext=txt
color 0a
title Process Sniper v%version%
echo Processes attempted to shut down in the last session:>%outputfile%.%outfileext%
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo ::    Process Sniper v%version%        ::
echo ::          writen by John Allen        ::
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo.
goto choice
exit /b
:list
wmic process get Name, ProcessID
goto choice
:kill
set /p input=Enter the process name/PID you wish to snipe:
taskkill /pid %input%
echo %input%>>%outputfile%.txt
goto choice
:close
cls
color 0c
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo ::    You have been using        ::
echo ::    Process Sniper v%version%        ::
echo ::           writen by John Allen        ::
echo ::         Press any key to close...        ::
echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
pause>null
DEL null
exit
:choice
echo Choose from the following:
echo 1.) List processes currently running
echo 2.) Snipe a process by name/PID
echo 3.) Exit Process Sniper v%version%
choice /c 123 /n
if errorlevel 1 set gt=list
if errorlevel 2 set gt=kill
if errorlevel 3 set gt=close:
goto %gt%
 
 

No comments:

Post a Comment