Is there a way to do this purely in a .bat file?
The purpose is to launch iexplore.exe
, then kill just that instance when it's finished.
Is there a way to do this purely in a .bat file?
The purpose is to launch iexplore.exe
, then kill just that instance when it's finished.
Since the highest rated answer so far uses another, built-in tool of Windows, here is another take, based on a temporary JScript script executed via WSH (Windows Scripting Host), which is also included in Windows.
One advantage to calling wmic.exe is that this does not rely on the output of wmic.exe, should it ever change (not likely, but anyway):
Here's what I use:
The directory is set to the directory that the cmd file is located in. Change
dir
to alter that. Modifycmd
to change which command is run.If you want a stop.cmd that kills it, it would look like this
I think you can't do that with simple command line utilities, as IE actually spawns child processes for each tab, i.e. if IE is not yet running you would get one parent IE process and a child process for the tab, and if IE is already running you would simply get a single child process.
It will be even quite tricky when you write your own tool to kill IE because when you kill a child (tab) process, IE will automatically recover this tab.
See also this related question: How to obtain process of newly created IE8 window? (though there is no good answer there).
A slight variation on the answer provided by @kybernetikos since it has a parsing issue. Note the line
if %%j gr 0 (
Ummm, TaskList & TaskKill?!
Most often you do know what task you start - in this case, which page iexplorer shall show.
So how about
It will kill all instances of something showing your page title, but with a specific title most often there should be exactly one.
Tom