Page 1 of 1

Making Force Close Batch

Posted: 30 Jan 2012 19:53
by paul.darsey
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.

Re: Making Force Close Batch

Posted: 30 Jan 2012 20:34
by paul.darsey

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

Re: Making Force Close Batch

Posted: 30 Jan 2012 21:02
by Liviu
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

Re: Making Force Close Batch

Posted: 30 Jan 2012 21:06
by paul.darsey
Thanks for your 2 cents.

Re: Making Force Close Batch

Posted: 30 Jan 2012 21:09
by paul.darsey
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....

Re: Making Force Close Batch

Posted: 30 Jan 2012 21:24
by orange_batch
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.

Re: Making Force Close Batch

Posted: 30 Jan 2012 21:35
by Liviu
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

Re: Making Force Close Batch

Posted: 31 Jan 2012 02:47
by alan_b
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.

Re: Making Force Close Batch

Posted: 31 Jan 2012 20:48
by paul.darsey
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.

Re: Making Force Close Batch

Posted: 01 Feb 2012 03:42
by alan_b
Sorry, I regret being so harsh with you.

I wish you well as you learn

Regards
Alan

Re: Making Force Close Batch

Posted: 01 Feb 2012 21:05
by paul.darsey
Hey man, all is forgotten, you live and you learn, right?

Sorry about my attitude as well...

Paul