简体   繁体   English

如何从批处理文件打开和关闭 Internet Explorer?

[英]How to Open and Close Internet Explorer from batch file?

I Have a batch file which has to launch Internet explorer and open www.google.com .我有一个必须启动 Internet Explorer 并打开www.google.com的批处理文件。 When the whole page loads finishing it should kill the IE process ie close all instances of IE in that system.当整个页面加载完成时,它应该终止 IE 进程,即关闭该系统中的所有 IE 实例。 My batch file has following two lines.我的批处理文件有以下两行。

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

But after loading it is not closing the IE instance.但加载后它并没有关闭 IE 实例。

If I am having seperate batch file with with only single line taskkill /IM iexplore.exe /F .如果我有单独的批处理文件,只有单行taskkill /IM iexplore.exe /F This batch file closes the IE instance.此批处理文件关闭 IE 实例。

What is going wrong in First Batch file. First Batch 文件出了什么问题。

PS Batch file is in Internet Explorer folder of program files. PS 批处理文件位于 Internet Explorer 程序文件的文件夹中。

I don't understand exactly your aim to open and to close immediately Internet explorer ?我不明白您的目标是立即打开和关闭 Internet Explorer 吗? but here is an example with a sleep to show you how it does work !但这里有一个带有睡眠的示例,向您展示它是如何工作的!

@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

And if you want to see more features like how to start a process and how to kill one process or multiple processes at once that interact with user input with a dynamic menu you should take a look at this post ==> How to check and correct user input when he omit the extension .exe to kill the process?如果您想了解更多功能,例如如何启动一个进程以及如何一次终止一个或多个进程与用户输入交互的动态菜单,您应该看看这篇文章 ==> 如何检查和更正用户输入时省略扩展名 .exe 以终止进程?

Try this alternative without confirmation from the user input :在没有用户输入确认的情况下尝试此替代方法:

@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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM