Go Back   TechArena Community > Technical Support > Computer Help > Windows XP > Customize XP
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , ,

.Bat file to kill processes upon confirmation

Customize XP


Reply
 
Thread Tools Search this Thread
  #1  
Old 24-02-2009
Member
 
Join Date: Feb 2009
Posts: 10
.Bat file to kill processes upon confirmation

Hi all,

I'd would like some help creating a simple (yeah i know n00b here) .Bat file that kills processes but 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!

Steve

Reply With Quote
  #2  
Old 25-02-2009
Tim Meddick
 
Posts: n/a
Re: .Bat file to kill processes upon confirmation

I don't quite understand you - the quoted commandline (taskkill /im
iPodService.exe /f) does NOT require any user intervention (i.e. for you to
confirm). So what's stopping you from just putting a list of such
commands - one for each unwanted process - into a batch file and away it
will go!?

Plus, on using the choice command - if you mean choice.exe - then an example
of it's use in a batch file might be:
----------------------------------------------
@echo off

choice Do you want to proceed
if ERRORLEVEL 2 goto end

echo Proceeding then...
myprogram.exe

:end
----------------------------------------------
Cheers, Tim Meddick, Peckham, London.



Reply With Quote
  #3  
Old 25-02-2009
Tim Meddick
 
Posts: n/a
Re: .Bat file to kill processes upon confirmation

I looked at your post again, I think I get it now. You WANT some user
intervention (i.e. for you to press Y to proceed).

The following should do what you ask:

--------------------------------------------------------------------------------------------
@echo off
choice Stop specified running processes
if ERRORLEVEL 2 goto OUT

echo Attempting to halt specified processes..
taskkill /im iPodService.exe /f
goto end

:OUT
echo Operation cancelled.
:end
--------------------------------------------------------------------------------------------


However, make sure that either CHOICE.COM (Win9x) or CHOICE.EXE (WinNT 2K
XP) is in the WINDOWS\system32 folder. If not, you can download a free, XP
compatible version, by clicking on this link:

http://www.dynawell.com/download/Res...nNT/choice.zip

Good luck, Tim Meddick, Peckham, London.



Reply With Quote
  #4  
Old 25-02-2009
Nil
 
Posts: n/a
Re: .Bat file to kill processes upon confirmation

On 24 Feb 2009, stevetilsed <stevetilsed.3o4jzd@DoNotSpam.com> wrote
in microsoft.public.windowsxp.customize:

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


Something like this should work. It checks to see if the program is
running, and if it is, it asks you if you want to kill it or not:

=============cut here===============

@echo off
rem substitute the (case sensitive) name of the
rem program you want to kill in the line below.
set Program=notepad.exe

tasklist | findstr "%Program%"
if %errorlevel% EQU 1 (GOTO NotRunning) else GOTO KillX
GOTO End

:KillX
echo.
echo.
choice /m " Do you want to kill %Program%?"
if %errorlevel% GTR 1 GOTO CancelledX
taskkill /f /im %Program%
GOTO END

:NotRunning
echo.
echo.
echo %Program% isn't running.
GOTO END

:CancelledX
echo.
echo.
echo Operation cancelled...
GOTO END

:END
echo.
echo.
echo All done!
echo.
echo.
pause

Reply With Quote
  #5  
Old 25-02-2009
ju.c
 
Posts: n/a
Re: .Bat file to kill processes upon confirmation

Use ProcessUtility to kill the process properly.

ProcessUtility 2.03 25 kb (Freeware)
Command Line Process Viewer/Killer/Suspender
Info: http://www.beyondlogic.org/solutions...rocessutil.htm
Download: http://www.beyondlogic.org/solutions...process203.zip


Usage:

ProcessUtility.exe [-v] [-t] [-c]
ProcessUtility.exe [-q] [Process Name/PID] [timeout sec(optional)]
ProcessUtility.exe [-k] [-s] [-r] [Process Name/PID]
ProcessUtility.exe [-p] [Process Name/PID]
{RealTime|High|AboveNormal|Normal|BelowNormal|Low}
ProcessUtility.exe [-a] [Process Name/PID] [Mask(To Set)]

-v View Processes.
-t View Kernel and User CPU Times.
-c View Process Creation Times.
-q Send WM_CLOSE Message. Default timeout is 60 Sec
-k Kill Process. (Terminate)
-s Suspend Process.
-r Resume Suspended Process.
-p Set Process Priority.
-a Get/Set Affinity Mask of Process.

PROCUTIL -q [PID] 5


ju.c


"stevetilsed" <stevetilsed.3o4jzd@DoNotSpam.com> wrote in message news:stevetilsed.3o4jzd@DoNotSpam.com...
>
> Hi all,
>
> I'd would like some help creating a simple (yeah i know n00b here) .Bat
> file that kills processes *but* 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!
>
> Steve
>
>
> --
> stevetilsed
> ------------------------------------------------------------------------
> stevetilsed's Profile: http://forums.techarena.in/members/stevetilsed.htm
> View this thread: .Bat file to kill processes upon confirmation
>
> http://forums.techarena.in
>


Reply With Quote
  #6  
Old 25-02-2009
ju.c
 
Posts: n/a
Re: .Bat file to kill processes upon confirmation

Please don't delete previous posts, thanks.


"Tim Meddick" <timmeddick@gawab.com> wrote in message news:uKMTyttlJHA.5920@TK2MSFTNGP06.phx.gbl...
> I looked at your post again, I think I get it now. You WANT some user
> intervention (i.e. for you to press Y to proceed).
>
> The following should do what you ask:
>
> --------------------------------------------------------------------------------------------
> @echo off
> choice Stop specified running processes
> if ERRORLEVEL 2 goto OUT
>
> echo Attempting to halt specified processes..
> taskkill /im iPodService.exe /f
> goto end
>
> :OUT
> echo Operation cancelled.
> :end
> --------------------------------------------------------------------------------------------
>
>
> However, make sure that either CHOICE.COM (Win9x) or CHOICE.EXE (WinNT 2K
> XP) is in the WINDOWS\system32 folder. If not, you can download a free, XP
> compatible version, by clicking on this link:
>
> http://www.dynawell.com/download/Res...nNT/choice.zip
>
> Good luck, Tim Meddick, Peckham, London.


Reply With Quote
  #7  
Old 26-02-2009
Member
 
Join Date: Feb 2009
Posts: 10
Re: .Bat file to kill processes upon confirmation

Cheers guys that worked wonders!

Reply With Quote
  #8  
Old 26-02-2009
Ace Hung
 
Posts: n/a
Re: .Bat file to kill processes upon confirmation

stevetilsed wrote:
> Hi all,
>
> I'd would like some help creating a simple (yeah i know n00b here) .Bat
> file that kills processes *but* 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!
>
> Steve
>
>


Use Process Explorer to kill unwanted processes. It is a free download
from Microsoft.

Reply With Quote
  #9  
Old 26-02-2009
ju.c
 
Posts: n/a
Re: .Bat file to kill processes upon confirmation

Please don't delete previous posts, thanks.


"stevetilsed" <stevetilsed.3o6hfc@DoNotSpam.com> wrote in message news:stevetilsed.3o6hfc@DoNotSpam.com...
>
> Cheers guys that worked wonders!
>
> --
> stevetilsed


Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows XP > Customize XP


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: ".Bat file to kill processes upon confirmation"
Thread Thread Starter Forum Replies Last Post
Task Manager CANNOT KILL PROCESSES j90qfj90q34fjwefi2 Vista Help 12 1 Week Ago 03:24 AM
VB code to kill running processes Banjiji Software Development 2 03-09-2009 04:58 PM
How to disable file delete confirmation dialog Francesca Operating Systems 3 30-03-2009 07:52 PM
Kill Windows Explorer Processes Easily in Windows Vista hatred Tips & Tweaks 1 11-02-2009 10:32 PM
how can i create a Batch file to kill some processes by name Hansel Ortiz -[BrEcHaWarr] Server Scripting 4 01-10-2008 09:32 AM


All times are GMT +5.5. The time now is 02:44 AM.