Windows – How to launch Edge with some cmd line args

command linecommand-line-argumentsmicrosoft-edgewindows

I'm using Windows 10. According to Microsoft Edge DevTools Protocol docs, I need to launch Edge with the --devtools-server-port cmd line arg.

i tried to do so via Console, but got an error:

'MicrosoftEdge.exe' is not recognized as an internal or external
command, operable program or batch file.

After checking out this thread, it turns out that there is apparently some magic with launching Edge by not using standard shortcut in Start menu.

How can we launch Edge with some cmd line args?

Best Answer

As pointed by @Clayton in comments to my question, in order to be able to use Microsoft Edge DevTools Protocol you have to make sure you actually have it in your system first. At the moment, this means that you should update your Windows 10 at least to April 2018 Update (version 1803) or later (see the link in my question for reference).

Then, you can launch Edge with DevTools Protocol server enabled by creating a shortcut on your Desktop with the command like this as a Target:

MicrosoftEdge.exe --devtools-server-port 9220 http://localhost:5000

After launching Edge with this shortcut, you now able to connect to Edge, for instance, with Visual Studio Code just like you used to do so to connect to Chrome. Here is a sample of a corresponding setup from launcn.json:

{
    "type": "edge",
    "request": "attach",
    "name": "Attach to Edge",
    "port": 9220,
    "webRoot": "${workspaceFolder}"
},

Of course for this to work, you need to have the Debugger for Edge extension installed in VS Code.