在 Windows 批处理文件中打开网页

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26223936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:45:27  来源:igfitidea点击:

Open a Web Page in a Windows Batch FIle

windowsbatch-filecmdshellexecute

提问by Ian Vink

I have a batch filethat does a bunch of things and at the end needs to open up a web browserto a page. Is there a way to, in essence, call ShellExecuteon a httpto open the web page?

我有一个批处理文件,可以做很多事情,最后需要打开一个网页浏览器。有没有办法,本质上,调用ShellExecute一个http来打开网页?

Windows Command Prompt

Windows 命令提示符

回答by Ross Ridge

You can use the startcommand to do much the same thing as ShellExecute. For example

您可以使用该start命令执行与ShellExecute. 例如

 start "" http://www.stackoverflow.com

This will launch whatever browser is the default browser, so won't necessarily launch Internet Explorer.

这将启动任何浏览器是默认浏览器,因此不一定会启动 Internet Explorer。

回答by Daryl Gill

unfortunatly, the best method to approach this is to use Internet Explorer as it's a browser which is garunteed to be on Windows based machines. This will also bring compatibility of other users which might have alternative browsers such as firefox, chrome, opera..etc,

不幸的是,解决这个问题的最佳方法是使用 Internet Explorer,因为它是一种可以在基于 Windows 的机器上运行的浏览器。这也将带来其他用户的兼容性,这些用户可能有其他浏览器,如 Firefox、chrome、opera.. 等,

start iexplore.exe http://www.website.com

回答by user4481177

When you use the start command to a website it will use the default browser by default but if you want to use a specific browser then use start iexplorer.exe www.website.com

当您对网站使用 start 命令时,它将默认使用默认浏览器,但如果您想使用特定浏览器,请使用 start iexplorer.exe www.website.com

Also you cannot have http://in the url.

你也不能http://在网址中。

回答by stackers

Start did not work for me.

开始对我不起作用。

What did was use firefox http://www.stackoverflow.comor chrome http://www.stackoverflow.com.

所做的是使用firefox http://www.stackoverflow.comchrome http://www.stackoverflow.com

Obviously not great for distributing it, but if you're using it for a specific machine, it should work fine.

显然不适合分发它,但是如果您将它用于特定机器,它应该可以正常工作。