hidden hit counter
Help!

.Bat file to kill processes upon confirmation

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Customize RSS
Next:  Messenger 5.1 says other contact has no webcam...  
Author Message
stevetilsed
External


Since: Feb 24, 2009
Posts: 1



PostPosted: Tue Feb 24, 2009 7:10 pm    Post subject: .Bat file to kill processes upon confirmation
Archived from groups: microsoft>public>windowsxp>customize (more info?)

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: http://forums.techarena.in/customize-xp/1129477.htm

http://forums.techarena.in
Back to top
Tim Meddick
External


Since: Feb 16, 2009
Posts: 128



PostPosted: Tue Feb 24, 2009 7:10 pm    Post subject: Re: .Bat file to kill processes upon confirmation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.
Back to top
Tim Meddick
External


Since: Feb 16, 2009
Posts: 128



PostPosted: Tue Feb 24, 2009 8:10 pm    Post subject: Re: .Bat file to kill processes upon confirmation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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/ResKit/Microsoft/WinNT/choice.zip

Good luck, Tim Meddick, Peckham, London.
Back to top
Nil
External


Since: Oct 13, 2005
Posts: 4



PostPosted: Wed Feb 25, 2009 1:10 am    Post subject: Re: .Bat file to kill processes upon confirmation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 24 Feb 2009, stevetilsed <stevetilsed.3o4jzd DeleteThis @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
Back to top
ju.c
External


Since: Jan 18, 2009
Posts: 14



PostPosted: Wed Feb 25, 2009 4:34 am    Post subject: Re: .Bat file to kill processes upon confirmation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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/processutil/processutil.htm
Download: http://www.beyondlogic.org/solutions/processutil/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.TakeThisOut@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: http://forums.techarena.in/customize-xp/1129477.htm
>
> http://forums.techarena.in
>
Back to top
ju.c
External


Since: Jan 18, 2009
Posts: 14



PostPosted: Wed Feb 25, 2009 4:35 am    Post subject: Re: .Bat file to kill processes upon confirmation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Please don't delete previous posts, thanks.


"Tim Meddick" <timmeddick RemoveThis @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/ResKit/Microsoft/WinNT/choice.zip
>
> Good luck, Tim Meddick, Peckham, London.
Back to top
stevetilsed
External


Since: Feb 26, 2009
Posts: 1



PostPosted: Wed Feb 25, 2009 3:10 pm    Post subject: Re: .Bat file to kill processes upon confirmation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Cheers guys that worked wonders!


--
stevetilsed
------------------------------------------------------------------------
stevetilsed's Profile: http://forums.techarena.in/members/stevetilsed.htm
View this thread: http://forums.techarena.in/customize-xp/1129477.htm

http://forums.techarena.in
Back to top
Ace Hung
External


Since: Feb 26, 2009
Posts: 1



PostPosted: Wed Feb 25, 2009 10:10 pm    Post subject: Re: .Bat file to kill processes upon confirmation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.
Back to top
ju.c
External


Since: Jan 18, 2009
Posts: 14



PostPosted: Thu Feb 26, 2009 1:22 am    Post subject: Re: .Bat file to kill processes upon confirmation [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Please don't delete previous posts, thanks.


"stevetilsed" <stevetilsed.3o6hfc RemoveThis @DoNotSpam.com> wrote in message news:stevetilsed.3o6hfc@DoNotSpam.com...
>
> Cheers guys that worked wonders!
>
> --
> stevetilsed
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Customize All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum