batch taskkill doesn't work sometimes

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
princess
Posts: 6
Joined: 11 Feb 2013 02:29

batch taskkill doesn't work sometimes

#1 Post by princess » 11 Feb 2013 02:41

Hallo everybody,

I do not have experience with own Batch-files and have a problem with this simple code:

call "iexplore.exe" "www.google.de"
taskkill /im iexplore.exe
call "iexplore.exe" "www.google.de"
taskkill /im iexplore.exe

of course google.de is only an example, the programm should reactivate a hardware with the iExplorer. It works, BUT:

If there is an Internet Explorer open, all run perfectly. (new window is open, close and another one also open and close. The iExplorer which was already open doesn't close or something else.)
My Problem:
If there is no iExplorer already open,
the first Explorer starts and wait until Ii manual close it. Then The second one is open and also wait until closing.

Please help me, where is the problem? :?

ng princess

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch taskkill doesn't work sometimes

#2 Post by foxidrive » 11 Feb 2013 05:34

Try this:

Code: Select all

@echo off
start "" "iexplore.exe" "www.google.de"
ping localhost -n 10 >nul
taskkill /f /im iexplore.exe
start "" "iexplore.exe" "www.google.com"
ping localhost -n 10 >nul
taskkill /f /im iexplore.exe
pause

princess
Posts: 6
Joined: 11 Feb 2013 02:29

Re: batch taskkill doesn't work sometimes

#3 Post by princess » 11 Feb 2013 08:41

Thanks but it doesn't work!

I tried it with start, call, /f, /t... nothing helped :cry:

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch taskkill doesn't work sometimes

#4 Post by foxidrive » 11 Feb 2013 09:16

It works here. What errors do you get?

princess
Posts: 6
Joined: 11 Feb 2013 02:29

Re: batch taskkill doesn't work sometimes

#5 Post by princess » 12 Feb 2013 01:02

In no case it works. Whether the iExplorer is open or closed, i have to close the window manually.


ERROR: Invalid query.
ERROR: Invalid query.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch taskkill doesn't work sometimes

#6 Post by foxidrive » 12 Feb 2013 01:17

Did you copy and paste it?

Which version of Windows are you using?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch taskkill doesn't work sometimes

#7 Post by foxidrive » 12 Feb 2013 01:20

With Internet Explorer open I get this on the console at the end.

SUCCESS: The process "iexplore.exe" with PID 6484 has been terminated.
SUCCESS: The process "iexplore.exe" with PID 4620 has been terminated.
SUCCESS: The process "iexplore.exe" with PID 7648 has been terminated.
SUCCESS: The process "iexplore.exe" with PID 7676 has been terminated.
SUCCESS: The process "iexplore.exe" with PID 6772 has been terminated.
Press any key to continue . . .



You have to wait 10 seconds for each window to close.

princess
Posts: 6
Joined: 11 Feb 2013 02:29

Re: batch taskkill doesn't work sometimes

#8 Post by princess » 12 Feb 2013 01:32

thanks, but it doesn't work :(

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch taskkill doesn't work sometimes

#9 Post by foxidrive » 12 Feb 2013 01:45

You didn't answer my questions.

princess
Posts: 6
Joined: 11 Feb 2013 02:29

Re: batch taskkill doesn't work sometimes

#10 Post by princess » 12 Feb 2013 03:15

Oh sorry,

Copy and Paste, but with my own settings.
I use Windows XP Professional

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: batch taskkill doesn't work sometimes

#11 Post by foxidrive » 12 Feb 2013 03:35

princess wrote:Copy and Paste, but with my own settings.
I use Windows XP Professional


Sorry princess, but I have no idea what settings you use when you say it doesn't work.
It does work here in Windows 8 and XP professional, so it will work the same on your machine - unless your operating system has flaws or you have done something to alter it.

When you launch the batch file it will open google in IE, wait for 10 seconds and then close IE, and reopen IE in google again. 10 seconds later it will close IE.

Test it as it is written and if it doesn't work then we have to figure out why - maybe you called the batch file iexplore.bat, or some other fault is affecting it.

princess
Posts: 6
Joined: 11 Feb 2013 02:29

Re: batch taskkill doesn't work sometimes

#12 Post by princess » 12 Feb 2013 03:50

Thanks foxidrive,

i do not know why your suggestions does not work on my computer,
but now i have a way to solve it. its very dirty but that doesn't matter...

THANKS FOR YOUR ADVICE! :wink:

Post Reply