How to open URL in Microsoft Edge from the command line?
I need to open URL in Microsoft Edge (on Windows 10). When I invoke
start shell:AppsFolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge http://www.google.com
then Microsoft Edge is started correctly but it doesn't open the given URL (www.google.com, in this case). It opens Bing search where the given URL is used as a search term instead.
The following method should work via Command Prompt (cmd):
start microsoft-edge:http://www.cnn.com
Windows 10: Create a shortcut with this destination:
%windir%\system32\cmd.exe /c "start microsoft-edge:https://twitter.com"
I too was wondering why you can't just start microsoftedge.exe, like you do "old-style" applications in windows 10. Searching the web, I found the answer -- it has to do with how Microsoft implemented "Universal Apps".
Below is a brief summary taken from that answer, but I recommend reading the entire entry, because it gives a great explanation of how these "Universal Apps" are being dealt with. Microsoft Edge is not the only app like this we'll be dealing with.
Here's the link: http://www.itworld.com/article/2943955/windows/how-to-script-microsofts-edge-browser.html
Here's the summary from that page:
"Microsoft Edge is a "Modern" Universal app. This means it can't be opened from the command line in the traditional Windows manner: Executable name followed by command switches/parameter values. But where there's a will, there's a way. In this case, the "way" is known as protocol activation."
Kudos to the author of the article, Stephen Glasskeys.
and a shortcut:
C:\Windows\System32\cmd.exe /c start shell:AppsFolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge http://localhost:6516
I would like to recommend:
Microsoft Edge Run Wrapper
https://github.com/mihula/RunEdge
You run it this way:
RunEdge.exe [URL]
- where URL may or may not contains protocol (http://), when not provided, wrapper adds http://
- if URL not provided at all, it just opens edge
Examples:
RunEdge.exe http://google.com
RunEdge.exe www.stackoverflow.com
It is not exactly new way how to do it, but it is wrapped as exe file, which could be useful in some situations. For me it is way how to start Edge from IBM Notes Basic client.
Personally, I use this function which I created and put in my profile script ...\Documents\WindowsPowerShell\….profile
, feel free to use it. As I am from the UK, I prefer to go to .co.uk
where possible, if you are from another area, you can add your own country code.
# Function taking parameter add (address) and opens in edge.
Function edge {
param($add)
if (-not ($add -contains "https://www." -or $add -contains "http://www.")) {
if ($add[0] -eq "w" -and $add[1] -eq "w" -and $add[2] -eq "w") {
$add = "https://" + $add
} else {
$add = "https://www." + $add
}
}
# If no domain, tries to add .co.uk, if fails uses .com
if (-not ($add -match ".co" -or $add -match ".uk" -or $add -match ".com")) {
try {
$test = $add + ".co.uk"
$HTTP_Request = [System.Net.WebRequest]::Create($test)
$HTTP_Response = $HTTP_Request.GetResponse()
$add = $add + ".co.uk"
} catch{
$add = $add + ".com"
}
}
Write-Host "Taking you to $add"
start microsoft-edge:$add
}
Then you just have to call: edge google
in powershell to go to https://www.google.co.uk
Looks like things have changed and the previous solution doesn't work anymore.
However, here is the working command to launch CNN.com on Microsoft Edge:
microsoft-edge:http://www.cnn.com
It will do more or less the same thing in good old dos script fashion
set add=%1
if %add%$ ==$ set add="about:blank" && goto launch
rem http://
set test=%add:~0, 7%
if %test% == http:// goto launch
rem ftp://
set test=%add:~0, 6%
if %test% == ftp:// goto launch
rem https://
set test=%add:~0, 8%
if %test% == https:// goto launch
rem add http
set add=http://%add%
:launch
start microsoft-edge:%add%
I want to complement other answers here in regards to opening a blank tab in Microsoft Edge from command-line.
One observation that I want to add from my end is that Windows doesn't detect the command microsoft-edge
if I remove the trailing colon. I thought it would be the case when I've to open the browser without mentioning the target URL e.g. in case of opening a blank tab.
How to open a blank tab in Microsoft Edge?
- From run prompt -
microsoft-edge:about:blank
- From command prompt -
start microsoft-edge:about:blank
You can also initiate a search using Edge from run prompt. Let's say I've to search Barack Obama
then fire below command on run prompt-
microsoft-edge:Barack Obama
It starts Microsoft's Bing search website in Edge with Barack Obama
as search term.
microsoft-edge:http://google.com
(open google as desired)
microsoft-edge:
(just open)
ReferenceURL : https://stackoverflow.com/questions/31164253/how-to-open-url-in-microsoft-edge-from-the-command-line
'program story' 카테고리의 다른 글
RecyclerView에서 불일치가 감지되었습니다. 스크롤하는 동안 RecyclerView의 내용을 변경하는 방법 (0) | 2020.12.24 |
---|---|
"서명 된"키워드의 실제 사용은 무엇입니까? (0) | 2020.12.24 |
파이썬 데코레이터는 함수가 클래스에 속한다는 것을 잊게 만듭니다. (0) | 2020.12.24 |
루트 컨텍스트를 어떻게 지정합니까? (0) | 2020.12.24 |
파이썬에서 연결이 끊어 졌는지 확인하는 방법 (0) | 2020.12.24 |