.Bat file to kill processes upon co

February 24, 2009 at 09:45:00
Specs: Windows XP, N/a
Hi all,

I'd would like some help creating a simple (yeah i know n00b here) .Bat file that kills processes [b]but[/b] requires me to confirm i wish for this to be done.

The background:
We have several programs at work that are memory hungry when left open for some time (i have the program left open for months at a time) The program takes a while to load and validate so i tend never to close and restart. Basically i would like to create a .Bat file that kills the process when i enter the letter 'Y' and press enter. This way i would be able to add this to scheduled tasks for my breaks and if i am going on my break on time i could say yes and leave it to do the rest.

I have managed to manually kill a process on a home PC my example follows

taskkill /im iPodService.exe /f

However i do not understand the choice command.

Is this even possible?
Any help or guidance is much appreciated!


See More: .Bat file to kill processes upon co

Report •

February 24, 2009 at 15:45:20
@echo off
set /p yesno= Would you like to kill the process [y/n]:
if "%yesno%"=="" (echo You didnt enter anything - try again..) & (GOTO SETYESNO)
if /I "%yesno%"=="n" (GOTO NOKILL)
if /I "%yesno%"=="y" (GOTO KILL) else (echo Unrecognized command - try again) & (GOTO SETYESNO)

echo Killing Process...
taskkill statement (your taskkill statement)

echo Aborting kill...


The set /p command issues a prompt for the user to enter the contents for the variable.

The if /I command ignores case when comparing the variables.

For help with the taskkill command type taskkill /? at the command prompt.

Hope this helps.

Report •
Related Solutions

Ask Question