Making Force Close Batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

Making Force Close Batch

#1 Post by paul.darsey » 30 Jan 2012 19:53

Hey guys, making a batch to force any processes I chose to close...I have it running fine...just a simple code....

Code: Select all

@echo Off
color A4
:chooseProgram
echo.
set /p task="Hey, %username% what do you want to close?"
goto program
:program
taskkill /f /im "%task%"
exit


But, I was wondering if any of you can help me...I was interested in seeing if you can make code that will display a list of all the current processes...thanks in advance! You guys are great.

paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

Re: Making Force Close Batch

#2 Post by paul.darsey » 30 Jan 2012 20:34

Code: Select all

@echo Off
color A4
:chooseProgram
set /p task="Hey, %username% what do you want to close?"
goto program
:program
taskkill /f /im "%task%"
if ERRORLEVEL==1 goto chooseProgram
:leaving
cls
echo Y=yes
echo N=no
set /p task2="Are you done, %username%?"
if %task2%==N goto chooseProgram
if %task2%==n goto chooseProgram
if %task2%==Y goto exit
if %task2%==y goto exit
cls
echo WRONG CHOICE DUMMY!
ping 192.168.0.1 >null
goto leaving
:exit
exit

Liviu
Expert
Posts: 470
Joined: 13 Jan 2012 21:24

Re: Making Force Close Batch

#3 Post by Liviu » 30 Jan 2012 21:02

paul.darsey wrote:Hey guys, making a batch to force any processes I chose to close...I have it running fine...just a simple code....
...
But, I was wondering if any of you can help me...I was interested in seeing if you can make code that will display a list of all the current processes...thanks in advance! You guys are great.

There is the builtin tasklist for one, referenced in taskill's own help.

That said, and no offense intended, but this is one of those cases where I opine that if you have to ask then you probably shouldn't be doing it to begin with. Did, for example, your code snippet use "/F" and not use "/T" or "/FI" on purpose? Force-killing a task can potentially have bad system-wide side effects, so it better be done only as a desperate last resort, and even then it's a tad safer to use Task Manager's "end process".

Just my 2c,
Liviu

paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

Re: Making Force Close Batch

#4 Post by paul.darsey » 30 Jan 2012 21:06

Thanks for your 2 cents.

paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

Re: Making Force Close Batch

#5 Post by paul.darsey » 30 Jan 2012 21:09

That said, and no offense intended, but this is one of those cases where I opine that if you have to ask then you probably shouldn't be doing it to begin with


It was taken offensively...thanks for your help when someone is trying to start learning something new....

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Making Force Close Batch

#6 Post by orange_batch » 30 Jan 2012 21:24

Well as he said, force-terminating processes is unsafe work best done with only a few clicks using task manager, however I'm not going to wag a finger.

Here's my own vbscript based tasklister which is in some ways better than tasklist, and will work on Windows XP Home where tasklist is nonexistent anyway:

viewtopic.php?f=3&t=2068&p=9334&hilit=task#p9334

viewtopic.php?f=3&t=1809&p=8712&hilit=kill#p8712

Enjoy.

Liviu
Expert
Posts: 470
Joined: 13 Jan 2012 21:24

Re: Making Force Close Batch

#7 Post by Liviu » 30 Jan 2012 21:35

paul.darsey wrote:It was taken offensively...thanks for your help when someone is trying to start learning something new....

A fair forewarning is often helpful as well, and that's all I meant to say. Once you delve deeper into the internals, processes, shared memory, global objects, files, pipes, transactions etc. it becomes apparent what force-killing a task can do to the _rest_ of the system.

My last advice here, if that's what you after learning, set yourself up with a virtual machine (virtual box, virtual pc, vmware, whatever) and test this kind of things inside the sandbox.

Bye,
Liviu

alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: Making Force Close Batch

#8 Post by alan_b » 31 Jan 2012 02:47

paul.darsey wrote:
That said, and no offense intended, but this is one of those cases where I opine that if you have to ask then you probably shouldn't be doing it to begin with


It was taken offensively...thanks for your help when someone is trying to start learning something new....

With all due respect, and I really mean that, you are being childishly infantile.

If you take offense when warned of danger,
you should stop doing things you do not understand.

paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

Re: Making Force Close Batch

#9 Post by paul.darsey » 31 Jan 2012 20:48

With all due respect, and I really mean that, you are being childishly infantile.

If you take offense when warned of danger,
you should stop doing things you do not understand.


Yes sir, thanks for your advice.

alan_b
Expert
Posts: 357
Joined: 04 Oct 2008 09:49

Re: Making Force Close Batch

#10 Post by alan_b » 01 Feb 2012 03:42

Sorry, I regret being so harsh with you.

I wish you well as you learn

Regards
Alan

paul.darsey
Posts: 20
Joined: 30 May 2011 18:44

Re: Making Force Close Batch

#11 Post by paul.darsey » 01 Feb 2012 21:05

Hey man, all is forgotten, you live and you learn, right?

Sorry about my attitude as well...

Paul

Post Reply