How to open a URL with cmd?

后端 未结 9 1509
南方客
南方客 2021-02-20 03:48

I already know that to open a webpage with the default browser you use: start www.google.com. However, I\'m trying to open a URL that contains a \'&\' in it for

9条回答
  •  你的背包
    2021-02-20 04:23

    Powershell

    By passing through powershell : powershell Start-Process .

    If you don't specify browser, then URL is open in your default browser. Mine is Google Chrome, so i have added chrome. For internet explorer, it will be iexplorer and for Mozilla Firefox, this is firefox.

    Examples from a CMD prompt :

    powershell Start-Process chrome http://google.com/
    

    or a little bit shorter :

    powershell Start-Process http://google.com/ 
    

    or even more shorter :

    powershell start http://google.com
    

    However, in your case, type in the one hand powershell command to goto powershell prompt. In the other hand, just type one of the following command line by specifying URL with "" in order to dodge the & effect as explained by jgmh above :

    start "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
    

    or by chosing a specific browser such as firefox :

    start firefox "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
    

    or else :

    [System.Diagnostics.Process]::Start("firefox.exe","https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world")
    

    Finally, type exit in order to quit the powershell prompt.

    CMD


    Using start command only

    idris19's method is really handy !

    This command line can also help you because you are able to indicate your browser : start .

    As said before, URL is open in your default browser if none is specified.

    For instance :

    start http://google.com
    

    or

    start chrome http://google.com
    

    But, in your case, don't forget to add "" to avoid & issue and mention your browser to not run URL in another cmd window :

    start chrome "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
    

    You can add -incognito flag to goto an incognito browser if necessary :

    start chrome "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world" -incognito
    

    Using windows explorer

    Furthermore, you can use windows explorer as following : explorer . It always will open your URL in the default browser.

    Example :

    explorer http://google.com
    

    As previously mentioned, don't forget the double quotes in your case due to & special character :

    explorer "https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world"
    

    Note : Tested on Windows 10 64bits.

    P.S : Please, don't hesitate to edit my answer because i probably made grammatical mistakes due to my low english level. Thanks ! Best regards :-)

提交回复
热议问题