我已经知道用你使用的默认浏览器:start www.google.com
打开网页。但是,我正在尝试打开一个包含'&‘的URL,例如:
https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world
如果我使用:
start https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world
它不会工作,因为有一个&
发布于 2017-06-13 14:00:58
&
是bash中的一个特殊字符,所以如果URL包含一个特殊字符,您只需这样做:
start "" "your url"
发布于 2017-06-13 13:43:48
每次出现与符号(&)字符时,都必须使用^字符对其进行转义。
start https://www.google.dz/?gws_rd=cr,ssl^&ei=rXc_WYq3Msy2abGXpugH#safe=off^&q=hello+world
发布于 2020-11-18 08:10:30
Powershell
通过powershell:powershell Start-Process <browser> <URL>
。
如果未指定浏览器,则URL将在默认浏览器中打开。我的浏览器是Google Chrome,所以我添加了chrome
。对于internet explorer,它将是iexplorer
,而对于Mozilla Firefox,它将是firefox
。
来自CMD提示符的示例:
powershell Start-Process chrome http://google.com/
或者更短一点:
powershell Start-Process http://google.com/
或者更短一些:
powershell start http://google.com
但是,在您的示例中,输入one hand powershell
命令转到powershell提示符。另一方面,只需输入以下命令行中的一个,通过使用""
指定URL,以避开上面jgmh所解释的&
效果:
start "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
或通过选择特定的浏览器,如firefox
:
start firefox "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
否则:
[System.Diagnostics.Process]::Start("firefox.exe","https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world")
最后,输入exit
以退出powershell提示符。
CMD
仅使用start命令
Idris19的方法真的很方便!
此命令行也可以帮助您,因为您能够指示您的浏览器:start <browser> <URL>
。
如前所述,如果未指定URL,则会在默认浏览器中打开URL。
例如:
start http://google.com
或
start chrome http://google.com
但是,在您的情况下,不要忘记添加""
以避免&
问题和提到您的浏览器不要在另一个命令窗口中运行URL:
start chrome "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
如有必要,您可以添加-incognito
标志以转到隐身浏览器:
start chrome "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world" -incognito
使用windows资源管理器
此外,您可以使用windows资源管理器,如下所示:explorer <URL>
。It always将在默认浏览器中打开您的网址。
示例:
explorer http://google.com
如前所述,不要忘记由于&
特殊字符而在大小写中使用双引号:
explorer "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
Note:在Windows10 64位上测试。
附言:请不要犹豫修改我的答案,因为我可能因为我的英语水平较低而犯了语法错误。谢谢!致以最良好的问候:-)
https://stackoverflow.com/questions/44513063
复制相似问题