通过 Windows 命令行启动网站
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3739327/
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
Launching a website via windows commandline
提问by Nathan
I have a program launching a website via the following command.
我有一个程序通过以下命令启动网站。
cmd "start /max http://url.com"
When launching a website via this method it uses the default browser with its default settings for opening a new window. for example, Firefox and IE will open the window inside the tab of an existing window if they are set to do so. I have reports of IE 6 replacing the content of a current opened window with the content of url.com. I've tested this and sure enough when IE 6 is set as the default browser and with a current webpage opened the above will replace the content of the opened window with url.com rather than opening a fresh window.
通过此方法启动网站时,它使用默认浏览器及其默认设置打开新窗口。例如,Firefox 和 IE 将在现有窗口的选项卡内打开窗口,如果它们被设置为这样做的话。我有报告称 IE 6 将当前打开的窗口的内容替换为 url.com 的内容。我已经对此进行了测试,当 IE 6 被设置为默认浏览器并且打开当前网页时,上面的内容将用 url.com 替换打开的窗口的内容,而不是打开一个新窗口。
Upon running some tests I see the command listed here:
运行一些测试后,我看到这里列出的命令:
cmd "start /max iexplore.exe http://url.com"
will consistently open a new window( with Internet Explorer of course) regardless of an existing window being present or not.
无论现有窗口是否存在,都将始终打开一个新窗口(当然使用 Internet Explorer)。
Can anyone tell me if I'm missing a silly setting in IE 6 or if there is a way to duplicate the "always open a new window" functionality exhibited by calling iexplore.exe directly, but with calling the user default browser instead.
谁能告诉我我是否遗漏了 IE 6 中的一个愚蠢设置,或者是否可以通过直接调用 iexplore.exe 来复制“始终打开新窗口”功能,但改为调用用户默认浏览器。
采纳答案by Franci Penov
IE has a setting, located in Tools
/ Internet options
/ Advanced
/ Browsing
, called Reuse windows for launching shortcuts
, which is checked by default. For IE versions that support tabbed browsing, this option is relevant only when tab browsing is turned off (in fact, IE9 Beta explicitly mentions this). However, since IE6 does not have tabbed browsing, this option does affect opening URLs through the shell (as in your example).
IE具有设置,位于Tools
/ Internet options
/ Advanced
/ Browsing
,称为Reuse windows for launching shortcuts
,这是默认选中。对于支持标签浏览的IE版本,这个选项只有在标签浏览关闭时才相关(实际上IE9 Beta明确提到了这一点)。但是,由于 IE6 没有选项卡式浏览,此选项确实会影响通过外壳打开 URL(如您的示例中所示)。
回答by Jay Wick
You can just use
你可以使用
explorer "https://google.com"
Which will launch your default browser and navigate to that site.
这将启动您的默认浏览器并导航到该站点。
And on Mac I've using
在 Mac 上我使用
open "https://google.com"
回答by prime
start chrome https://www.google.com/
or start firefox https://www.google.com/
start chrome https://www.google.com/
或者 start firefox https://www.google.com/
回答by kjv
To open a URL with the default browser, you can execute:
要使用默认浏览器打开 URL,您可以执行:
rundll32 url.dll,FileProtocolHandler https://www.google.com
I had issues with URL parameters with the other solutions. However, this one seemed to work correctly.
我在使用其他解决方案时遇到了 URL 参数问题。然而,这个似乎工作正常。
回答by VaLo
You can start web pages using command line in any browser typing this command
您可以在任何浏览器中使用命令行输入此命令来启动网页
cd %your chrome directory%
start /max http://google.com
save it as bat and run it :)
将其另存为 bat 并运行它:)
回答by VitaminYes
Working from VaLo's answer:
从 VaLo 的回答开始:
cd %directory to browser%
%browser's name to main executable (firefox, chrome, opera, etc.)% https://www.google.com
start https://www.google.com
doesn't seem to work (at least in my environment)
start https://www.google.com
似乎不起作用(至少在我的环境中)
回答by Russell Abraham
Ok, The Windows 10 BatchFile is done works just like I had hoped. First press the windows key and R. Type mmc and Enter. In File Add SnapIn>Got to a specific Website and add it to the list. Press OK in the tab, and on the left side console root menu double click your site. Once it opens Add it to favourites. That should place it in C:\Users\user\AppData\Roaming\Microsoft\StartMenu\Programs\Windows Administrative Tools. I made a shortcut of this to a folder on the desktop. Right click the Shortcut and view the properties. In the Shortcut tab of the Properties click advanced and check the Run as Administrator. The Start in Location is also on the Shortcuts Tab you can add that to your batch file if you need. The Batch I made is as follows
好的,Windows 10 批处理文件已完成,就像我希望的那样。首先按下 windows 键和 R。输入 mmc 并回车。在文件中添加管理单元>转到特定网站并将其添加到列表中。在选项卡中按 OK,然后在左侧控制台根菜单中双击您的站点。打开后将其添加到收藏夹。这应该将它放在 C:\Users\user\AppData\Roaming\Microsoft\StartMenu\Programs\Windows 管理工具中。我在桌面上创建了一个文件夹的快捷方式。右键单击快捷方式并查看属性。在“属性”的“快捷方式”选项卡中,单击“高级”并选中“以管理员身份运行”。从位置开始也位于快捷方式选项卡上,您可以根据需要将其添加到批处理文件中。我做的批次如下
@echo off
title Manage SiteEnviro
color 0a
:Clock
cls
echo Date:%date% Time:%time%
pause
cls
c:\WINDOWS\System32\netstat
c:\WINDOWS\System32\netstat -an
goto Greeting
:Greeting
cls
echo Open ShellSite
pause
cls
goto Manage SiteEnviro
:Manage SiteEnviro
"C:\Users\user\AppData\Roaming\Microsoft\Start Menu\Programs\Administrative Tools\YourCustomSavedMMC.msc"
You need to make a shortcut when you save this as a bat file and in the properties>shortcuts>advanced enable administrator access, can also set a keybind there and change the icon if you like. I probably did not need :Clock. The netstat commands can change to setting a hosted network or anything you want including nothing. Can Canscade websites in 1 mmc console and have more than 1 favourite added into the batch file.
当您将其保存为 bat 文件时,您需要创建一个快捷方式,并在属性>快捷方式>高级启用管理员访问权限,也可以在那里设置键绑定并根据需要更改图标。我可能不需要:时钟。netstat 命令可以更改为设置托管网络或您想要的任何内容,不包括任何内容。可以在 1 mmc 控制台中 Canscade 网站,并将超过 1 个收藏添加到批处理文件中。