Problem when launching Edge using Active X Object inside Javascript

Zhu, Ligong 80 Reputation points
2024-03-07T13:30:10.7566667+00:00

Hi,

We are testing this line of code to launch Edge browser from our Javascript:

var WshShell = new ActiveXObject("Shell.Application");

WshShell.ShellExecute('msedge', window.location.protocol + "//" + window.location.host + "/ebb/" + fileName, "", "open", 1);

(protocol, host and fileName above are all runtime variables here and are all with correct values).

This line works most times and Edge browser can be launched successfully.

But in one of every four or five times, it won't do anything and no Edge browser can't be launced at all.

Our Edge is "Version 121.0.2277.112 (Official build) (64-bit)" on Windows 10.

Do you have anu suggestion what can be the cause?

Thanks,

Ligong

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,130 questions
{count} votes

Accepted answer
  1. ShiJieLi-MSFT 7,396 Reputation points Microsoft Vendor
    2024-03-11T07:58:59.92+00:00

    Hi @Zhu, Ligong,

    Thank you for your information. I have tested your code, but I can't reproduce this issue because it launches Microsoft Edge every time.

    This issue occurs in one of every four or five times, which sounds like something's wrong with the application itself. As a matter of fact, I suggest you repair Microsoft Edge in Control Panel --> Programs and Features --> Microsoft Edge --> Change.

    If repair does not fix this issue, I suggest you still use "iexplore.exe" for ShellExecute(), which is proved to work on your side.

    =================

    UPDATE

    There're 2 ways if you still need to launch Microsoft Edge (IE mode) via JavaScript code:

    • Add --user-data-dir=<path> command line for msedge (not iexplore.exe), but with a different <path> for each session.
    • If you use IE mode site list policies, you can configure sites like this with the merge-type="no-merge" attribute:

    <site url="contoso.com">

    <open-in merge-type="no-merge">IE11</open-in>

    </site>

    Then the site should be in its own unmerged IE session without modifying the JavaScript code.

    For more information, please read Does IE mode on Microsoft Edge support the 'no-merge' option that was supported in Internet Explorer 11?


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,

    Shijie Li

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful