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

Sponsored Links



how can i create a Batch file to kill some processes by name

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 23-09-2008
Hansel Ortiz -[BrEcHaWarr]
 
Posts: n/a
how can i create a Batch file to kill some processes by name

hi guys... i`ll be searching in the web trying to find a script to
kill one or various process, but i just can find
how to kill process by pid.

how can i to this.... just searching the name process like Starting
with X.... or task%..
something like that.. if someone could help..

i couldn`t find the sintax of the taskkill to refer this command to a
name.. just pid and others...

Reply With Quote
  #2  
Old 23-09-2008
Pegasus \(MVP\)
 
Posts: n/a
Re: how can i create a Batch file to kill some processes by name

Type taskkill /? at the Command Prompt to get the full help for this command
(and, for that, for any other console command!).
Reply With Quote
  #3  
Old 24-09-2008
Hansel Ortiz -[BrEcHaWarr]
 
Posts: n/a
Re: how can i create a Batch file to kill some processes by name

well.. i just need the reference to search a process for name, i used
taskkill /? and i dont know wich one to use :S


i Try this batch file version. but trying to change the syntax of
the "notepad.exe"
for examble --->>> "Note%" all processes that start with 'note'

@echo off
set prev=
FOR /F "tokens=2" %%i IN ('tasklist ^| Find /i "notepad.EXE"') DO CALL
:windowlist %%i
goto :EOF

:windowlist
if not "%prev%"=="" echo TASKKILL /PID %prev% /F
set prev=%1
Reply With Quote
  #4  
Old 24-09-2008
Pegasus \(MVP\)
 
Posts: n/a
Re: how can i create a Batch file to kill some processes by name

well.. i just need the reference to search a process for name, i used
taskkill /? and i dont know wich one to use :S


i Try this batch file version. but trying to change the syntax of
the "notepad.exe"
for examble --->>> "Note%" all processes that start with 'note'

@echo off
set prev=
FOR /F "tokens=2" %%i IN ('tasklist ^| Find /i "notepad.EXE"') DO CALL
:windowlist %%i
goto :EOF

:windowlist
if not "%prev%"=="" echo TASKKILL /PID %prev% /F
set prev=%1

================

The batch file you quote does something quite different from what you want:
It kills every "notepad" process except for the last one in the list. If you
want to kill all processes whose names contain the word "note" then you can
do it much more simply:

@echo off
setlocal EnableDelayedExpansion
set PIDs=
for /F "tokens=2" %%a in ('tasklist ^| find "note"') do set PIDs=!PIDs! /pid
%%a
echo TaskKill %PIDs% /F /T

Remove the word "echo" in the last line to activate the batch file.
Reply With Quote
  #5  
Old 01-10-2008
Andrew Mishechkin
 
Posts: n/a
Re: how can i create a Batch file to kill some processes by name

Here my cmd-file: pskill.cmd
-------------
@ECHO OFF
REM Using this bat-file: pskill ProcessName [RemoteComputerName] [UserName]
[UserPassword]
IF "%1"=="" (GOTO Error)
IF "%2"=="" (SET NodeName=.) ELSE (SET NodeName=%2)
IF NOT "%3"=="" (GOTO AnotherUser)
wmic /NODE:%NodeName% PROCESS WHERE (name="%1") CALL TERMINATE
GOTO End

:AnotherUser
SET UserName=%3
IF NOT "%4"=="" (SET Password=%4) ELSE (SET Password="")
wmic /NODE:%NodeName% /User:%UserName% /Password:%Password% PROCESS WHERE
(name="%1") CALL TERMINATE
GOTO End

:Error
ECHO Using this bat-file: pskill ProcessName [RemoteComputerName] [UserName]
[UserPassword]

:End
------------------
Reply With Quote
  #6  
Old 20-04-2011
Member
 
Join Date: Apr 2011
Posts: 2
how can i create a Batch file to kill some processes by name

Hello guys,

I have found a simple way to kill a task using the batch file...... it is as follows,

the command is "taskkill"

you can do this by,
  1. Knowing the PID of the process
  2. Knowing the image name of the process

For example,
If you want to end the notepad, then command is "taskkill /im notepad.exe
where "im" is the image name of the process. i.e. notepad

you can also end any process by using its PID also. the eg for this is,
"taskkill /pid 5264" where pid is process identifier and it may be 5264....

if you want to know the process name and process id, then u can see it in task manager. if pid is not displayed then go to view>select columns>process identifier in task manager..

you can also force to end the process so as not to display any message box . you can do it by, adding the /f command to it......
note that /f should be given as, "taskkill /f /im notepad.exe

you can also enter any number of within a single command....... to do so, enter as, "taskkill /im program1 /im program2 /im program3 and so on" or use the pid of the process in the same way.......

if you have any doubts you can type "taskkill /?" in command prompt to view the help.....

try it out.........
discover things.........
share your thoughts........
Reply With Quote
  #7  
Old 07-06-2012
Member
 
Join Date: Sep 2011
Posts: 1
Kill misc processes

I want to do just the opposite. I want to have a file with processses that I DON't want to disable because they are required, or the computer crashes. I want to kill everything no in a list.
Reply With Quote
  #8  
Old 07-06-2012
Member
 
Join Date: Jan 2006
Posts: 605
Re: how can i create a Batch file to kill some processes by name

You can try the below code or similar syntax to enable any kind of apps that you want.

Code:
cd "C:\Program Files\Adobe"
start Adobe
cd "C:\Program Files\Nokia PC Suite"
start Nokia PC Suite
cd "C:\Program Files\Microsoft Office"
start Microsoft Office
cd "C:\Program Files\Stardock\Realtek"
start Realtek
Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "how can i create a Batch file to kill some processes by name"
Thread Thread Starter Forum Replies Last Post
I want to create a TCP/IP Batch file aladdin Software Development 1 14-02-2012 10:59 PM
Help me create this batch file. bomblast Windows Software 1 31-10-2011 10:47 AM
End Multiple Processes With The Help Of Batch File Sheenas Operating Systems 6 21-04-2011 12:53 AM
How to create batch for RAR file extension Jayden Windows Software 1 13-04-2009 11:58 PM
How to create a Batch file Katty Software Development 1 10-01-2009 12:26 PM


All times are GMT +5.5. The time now is 11:51 PM.