How to script Microsoft's Edge browser

How to open Microsoft Edge from a command line or windows script

Like many developers, I've been exploring every new Windows 10 Insider Preview build, paying special attention to Microsoft's new Edge browser. Although Windows 10 hasn't been officially released, Edge has already proven itself to be a faster browser than its pokey Internet Explorer (IE) sibling.

So what about Edge's other features, especially those of interest to developers and admins? For example, many developers routinely use IE (and Firefox and Chrome) command line options to open the browser inside test scripts, or, create custom webpage shortcuts on the Windows desktop. Edge too, can also be "kicked off" in a script, but the technique to do so is different than the method developers have traditionally used to script IE or other browsers.

Protocol activation

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.

But before protocol activation can be used, we first need to know which protocols are supported or associated with the application.

There are two easy ways to do this:

  1. Examine the application's AppxManifest.xml file (located under the %SystemRoot%\SystemApps folder).
  2. Find app protocols in the HKCR\Extensions\ContractId\Windows.Protocol\ section of the registry.

To illustrate, we see a list of all windows protocols associated with the Edge browser in its AppxManifest.xml file...

Visual Studio AppxManifest protocols

...and the Windows registry:

Windows registry -- supported protocols

Armed with this knowledge, we can now start Edge from inside a script or command line, specifying the microsoft-edge protocol, and a URL action parameter: 

Run edge browser from command line


It's also easy to create desktop and start menu shortcuts -- simply run cmd.exe and wrap the action portion of the command in double quotes.

Edge browser shortcut

Finally, click the "Change Icon" button to use Edge's application icon. (MicrosoftEdge.exe is found in the %SystemRoot%\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe folder).

Edge browser icon

This story, "How to script Microsoft's Edge browser" was originally published by ITworld.

Copyright © 2015 IDG Communications, Inc.

7 inconvenient truths about the hybrid work trend
Shop Tech Products at Amazon