Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch MS Edge from c# winforms?

Tags:

c#

.net

winforms

The executable MicrosoftEdge.exe cannot be launched directly like other EXEs in windows. I confirmed that from my own experience, and by reading this and that.

I also cannot launch it via Process.Start("MicrosoftEdge.exe") in my c# winforms app.

There must be some way to launch Edge from winforms without resorting to 3rd-party app and other clutter. I have already tried the following, with no success:

  1. Process.Start("MicrosoftEdge.exe") - unhandled exception
  2. Process.Start("microsoft-edge") - unhandled exception
  3. Process.Start("%windir%\explorer.exe shell:Appsfolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge") - unhandled exception
  4. Process.Start(@"c:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe") - no exception, but nothing happens

Note: I can easily launch Chrome and Firefox using method #1 above.

How can I launch MS Edge from my .net winforms app?

like image 884
HerrimanCoder Avatar asked Sep 21 '16 21:09

HerrimanCoder


People also ask

How do I open Microsoft Edge from run?

How to start Microsoft Edge from the Run window. Press Win + R on the keyboard to open the Run window. In the Open field, type “microsoft-edge:” and press Enter on the keyboard or click or tap OK. Microsoft Edge is now open.

Where is Microsoft Edge located in C drive?

May 2021: Edge is located in C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe. It can be found by either goint to that location or shell:Appsfolder.

How do I open Edge chromium in CMD?

First, open the Start menu. You can do that by pressing the “Start” key. Type “cmd” and press Enter to open the Command Prompt window. After opening the command line window, use the “start msedge” command to open the Edge browser.


3 Answers

The ":" at the end is inportant, otherwise won't work

To open in blank:

System.Diagnostics.Process.Start("microsoft-edge:");

or specifying an address:

System.Diagnostics.Process.Start("microsoft-edge:http://www.google.com");
like image 57
user1845593 Avatar answered Oct 20 '22 19:10

user1845593


Process.Start can take 2 parameters

string url = "http://www.google.com";
System.Diagnostics.Process.Start("msedge.exe", url);

Browsers:

  • msedge.exe
  • chrome.exe
  • firefox.exe
  • iexplore.exe
like image 34
Ken Avatar answered Oct 20 '22 20:10

Ken


You can use a small workaround to open Microsoft Edge from CMD with this code

string url = "https://www.google.com";

// Starts Microsoft Edge with the provided URL; NOTE: /C to terminate CMD after the command runs
System.Diagnostics.Process.Start("CMD.exe", $"/C start msedge {url}");
like image 1
Florin Zamfir Avatar answered Oct 20 '22 18:10

Florin Zamfir