如何使用命令杀死上次打开的Internet Explorer窗口? [英] How to kill the last opened Internet Explorer window using a command?

查看:190
本文介绍了如何使用命令杀死上次打开的Internet Explorer窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个Windows命令文件来打开IE中的网页,等待它加载,然后关闭IE窗口。以下工作,但会杀死所有的IE窗口,所以任何已经打开之前运行.cmd也将被关闭。

I'm trying to write a Windows command file to open a webpage in IE, wait for it to load, then close the IE window. The following works but will kill all IE windows so any that were already open before running the .cmd will also get closed.

start iexplore.exe "page to load"
ping localhost -n 10 > nul
taskkill /IM iexplore.exe

我只想杀死打开的IE 。我知道我可以杀死一个特定的过程,如果我知道它的PID,但是如何从命令行中找到这个?有没有办法得到它在启动IE窗口?我真正想做的是:

I only want to kill the IE that was opened. I know I can just kill a particular process if I know its PID but how can find this from the command line? Is there a way to get it when starting the IE window? What I really want to do is:

start iexplore.exe "page to load"
ping localhost -n 10 > nul
taskkill /PID ?

在哪里?是打开的IE的PID,但我怎么能得到这个?

where ? is the PID of the IE that gets opened but how can I get this? This needs to run as a .cmd file without any input from a user.

推荐答案

IE已经支持自动化,没有点找到并杀死正确的进程:

IE already supports automation, there is no point in finding and killing the correct process:

Set IE = CreateObject("InternetExplorer.Application")
IE.visible=true
IE.navigate "http://stackoverflow.com/"
while IE.Busy
 WScript.Sleep 555
 wend
IE.Quit

另存为.vbs(使用父程序/批处理文件中的wscript.exe运行)

Save as .vbs (And run with wscript.exe from parent program/batch file)

这篇关于如何使用命令杀死上次打开的Internet Explorer窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆