|
| |||||||||
| Tags: bat, choice, file, programming, taskkill |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| .Bat file to kill processes upon confirmation 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 |
|
#2
| |||
| |||
| 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. |
|
#3
| |||
| |||
| 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. |
|
#4
| |||
| |||
| 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 |
|
#5
| |||
| |||
| 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 > |
|
#6
| |||
| |||
| 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. |
|
#7
| |||
| |||
| Re: .Bat file to kill processes upon confirmation
Cheers guys that worked wonders! |
|
#8
| |||
| |||
| 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. |
|
#9
| |||
| |||
| 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 |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |