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...
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!).
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
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.
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
------------------
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,
- Knowing the PID of the process
- 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........
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