【问题标题】:How to Open and Close Internet Explorer from batch file?如何从批处理文件中打开和关闭 Internet Explorer?
【发布时间】:2015-09-02 08:19:17
【问题描述】:

我有一个批处理文件,它必须启动 Internet Explorer 并打开 www.google.com。当整个页面加载完成时,它应该终止 IE 进程,即关闭该系统中的所有 IE 实例。我的批处理文件有以下两行。

iexplore.exe "www.google.com"
taskkill /IM iexplore.exe /F

但加载后并没有关闭 IE 实例。

如果我有单独的批处理文件,其中只有一行 taskkill /IM iexplore.exe /F。此批处理文件关闭 IE 实例。

First Batch 文件出了什么问题。

P.S 批处理文件在 Internet Explorer 程序文件的文件夹中。

【问题讨论】:

  • 在taskkill之前尝试睡眠
  • 这听起来像XY problem?。为什么要打开一个网页然后立即关闭它?
  • @DavidPostill 只是想尝试一下。它与任何问题或解决方案无关。

标签: internet-explorer batch-file cmd kill-process taskkill


【解决方案1】:

我不完全理解您打开和立即关闭 Internet Explorer 的目的?但这里有一个 sleep 的例子,向你展示它是如何工作的!

@echo off
Title Start and Kill Internet Explorer
Mode con cols=75 lines=5 & color 0B
echo(
echo                     Launching Internet Explorer ...
Start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" "www.google.com"
:: Sleep for 20 seconds
Timeout /T 20 /NoBreak>NUL
echo(
echo            Hit any Key to kill all instances of Internet Explorer
Pause>nul
Cls & Color 0C
echo(
echo              Killing Internet Explorer Please wait for a while ...
Taskkill /IM "iexplore.exe" /F
pause

如果您想了解更多功能,例如如何启动一个进程以及如何一次终止一个或多个进程,这些功能与动态菜单与用户输入交互,您应该看看这篇文章 ==> @987654321 @

在没有用户输入确认的情况下尝试这个替代方案:

@echo off
Title Start and Kill Internet Explorer
Mode con cols=75 lines=5 & color 0B
echo(
echo                     Launching Internet Explorer ...
Start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" "www.google.com"
:: Sleep for 10 seconds, you can change the SleepTime variable
set SleepTime=10
Timeout /T %SleepTime% /NoBreak>NUL
Cls & Color 0C
echo(
echo              Killing Internet Explorer Please wait for a while ...
Taskkill /IM "iexplore.exe" /F

【讨论】:

  • 我不需要任何手动帮助。它要求确认。我们可以不提示用户单击任何键吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-05
  • 1970-01-01
  • 2019-01-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多