Detect and Kill Windows Process

June 22, 2009 at 15:46:30
Specs: Windows XP
Hi All.

I'm struggling to write a batch file that checks to see if Internet Explorer is running and, if so, kill the process.

My batch file is as follows, and I've searched the internet to no avail.

Not sure if this even makes sense.... So please forgive me in advance.

***************************

@ECHO OFF

::------------ MAIN SCRIPT ---------------

CALL :KILL_IE
GOTO :EOF

::--------- BEGIN FUNCTIONS -----------

:KILL_IE

TASKLIST /FI "IMAGENAME eq IEXPLORE.EXE" > nul
IF NOT ERRORLEVEL==1 GOTO :EOF
TASKKILL /F /IM "iexplore.exe"
GOTO :EOF

::-----------------------------------------------------------------

:EOF

**************************

Any and all help / advice would be greatly appreciated.

Thanks,
FM


See More: Detect and Kill Windows Process

Report •


#1
June 22, 2009 at 18:06:26
It uses vbs..but it works. the >"c:\ie.vbs" and >>"c"\ie.vbs" should be on the previous line but this reply thing works terribly (:
@echo off
echo Set objShell = CreateObject("WScript.Shell")
>"C:\ie.vbs"
echo Set objWmi = GetObject("winmgmts:") >>"C:\ie.vbs"
echo strWmiq = "select * from Win32_Process where
name='iexplore.exe'" >>"C:\ie.vbs"
echo Set objQResult = objWmi.Execquery(strWmiq)
>>"C:\ie.vbs"
echo For Each objProcess In objQResult >>"C:\ie.vbs"
echo intRet = objProcess.Terminate(1) >>"C:\ie.vbs"
echo Next >>"C:\ie.vbs"
start C:\ie.vbs
sleep 2
del "C:\ie.vbs"
exit

Report •

#2
June 23, 2009 at 14:24:17
BatchFileCreator,

I truly appreciate the response and solution. However, can the above be accomplished without the use of vbscripting?

I'm trying to simply the solution and limit the use of other scripting languages.

Thanks,
FM


Report •

#3
June 23, 2009 at 19:39:58
TASKKILL /F /IM "iexplore.exe"

There ya go.


Report •

Related Solutions

#4
June 25, 2009 at 08:09:37
And if you want to constantly search It's

:START
TASKKILL /F /IM "iexplore.exe"
GOTO START

Simple :~)

***************************
Need BatchFile Help ?
Msg me :)
***************************


Report •

#5
June 25, 2009 at 14:30:04
Thanks much Razor2.3 and Mattio. However, I'm looking to call the TASKKILL operation after I've called some other batch file.

As I've mentioned above, I'm looking for something conditional.

CALL BATCH1
CALL :KILL
CALL BATCH2

:KILL "iexplore.exe" if it exists
otherwise go to next the BATCH file

I hope this makes more sense.

Thanks once again,
FM


Report •

#6
June 25, 2009 at 16:37:43
I'm not sure I'm following here; what has been posted will kill Internet Explorer if it's running, and will do nothing if it isn't. I'm not sure what calling a script before hand will affect that behavior.

Report •


Ask Question