我有一个批处理文件,必须启动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文件夹中。
答案 0 :(得分:9)
我完全不了解您打开并立即关闭Internet Explorer的目的?但这里有一个睡眠的例子,告诉你它是如何工作的!
@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
如果您想要查看更多功能,例如如何启动流程以及如何一次性杀死一个流程或多个流程,并通过动态菜单与用户输入交互,您应该看一下这篇文章==> How to check and correct user input when he omit the extension .exe to kill the process?
在未经用户输入确认的情况下尝试此替代方案:
@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