MSEdge starts itself with bad options or sometimes doesn't exit

d3x0r 0 Reputation points
2024-12-20T03:11:38.6+00:00

Was looking for more of an issue tracker for Edge...

I've run into this issue with edge, that actually chrome shares.

With a few batch files...

setupTask.bat

schtasks /create /tn @EdgeShutdownTest\runEdge /tr %~dp0msedge.bat /sc ONCE /st 00:00 /sd 01/01/2000

msedge.bat

start /wait "Title" "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --user-data-dir=c:\temp\edge-1 %*

test.bat

schtasks /run /tn @EdgeShutdownTest\runEdge

and probably endTest.bat

schtasks /delete /tn @EdgeShutdownTest\runEdge /f

setupTask creates a scheduled task that calls the msedge.bat in the same directory; scheduled tasks can't have arguments (don't seem to take arguments) so anything has to be done through a batch file or other simple task. the msEdge.bat just starts an instance of edge with start /wait so while edge is running, the batch file waits, and when you close the window (I use ctrl-W to close the tab, the X works, alt-F4, whatever), then the batch file completes and exits.

Test.bat triggers the batch file to run.... This can be monitored in the process group of the scheduler.

I was using task explorer from https://github.com/DavidXanatos/TaskExplorer Releases v 1.5.6 to watch the processes be created.

These are demonstrations that it does happen - it's a timing sensitive problem though; then I'll describe the issue.

https://youtu.be/ZrrDHJb0Khk is a demonstration of what I mean...

https://youtu.be/NCPdc77pSJQ continues with an example of having edge already there, then when the batch file runs, it immediately exits, but an edge window does show... a false exit is as bad as a failure to exit.....

At least the above is what should happen. What does happen is

  1. Sometimes when you close the edge tab/browser, the background edge process does not exit, so there's no visible UI available to do anything, and yet edge is still running in the background, and the batch file does not end. You can manually kill edge with task manager or the task explorer above, and then the batch file completes, and the test can trigger again. In this condition, the scheduled task is still running, and triggering with test.bat again does nothing.
  2. Sometimes, after a period of time, when you close the tab, edge starts another edge with the command line flag '--no-top-window', and the process list maintained by the task explorer above has a terminated cmd.exe and a terminated edge that then has this new edge under it. It doesn't get the original flags of --user-data-dir= , and the window that it has is a blank name, and most msedge processes do not have windows. I would be hard pressed to find this if I just start, because the parent process ID references a process that doesn't exist now, and without continuous monitoring it would be hard to establish that this chain of edge processes is the one that is bad. When this happens, the edge process did end, and the batch file ends, and the scheduled task can be run again. A new window is created, but the msedge that gets started by the batch file immediately exits after handing the work off to the existing msedge process; so the schedule task can be triggered again, the batch file thinks it exited, but it still exists on the screen. It might be tempting to run test.bat many more times, which will cause repeated tabs to be opened (if they have URL specified in the msedge.bat file; I think maybe the home screen auto collapses, but it can be that many many tabs can be open)

The above is actually done in a process that launches a browser to a webpage in kiosk mode, and can track the process, and perhaps receive update commands etc. The batch files demonstrate the behavior without involving the actual process, which is more elegant then it may seem from the above minimal test procedure.

I was testing on a slower box, a modern N100 processor with DDR5 memory and SSD disk - it's a nice little box, very fast memory; cpu is a little slow on a large compile, but runs edge just fine and the intended application.

When I was testing on my 13700K system, I couldn't get the behavior to happen, it's part of the videos above though, it does attempt to do the same thing, but is able to stop the processes it created. And maybe it's not after a time delay that it happens, maybe it's at a time when a new process gets created.

I did go through the initial setup - the msedge.bat contains a --user-data-dir which ends up having to do a first-run initialization to select importing data (don't), improve browsing experience( not needed), selecting a theme (probably not relevant to the issue), and then getting to the browser itself... which in this case is just there to be closed.

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

1 answer

Sort by: Most helpful
  1. ShiJieLi-MSFT 11,021 Reputation points Microsoft Vendor
    2024-12-20T07:52:20.2533333+00:00

    Hi @d3x0r ,

    It seems to have something to do with the Startup Boost feature (Edge-specific) and Background Mode (Chrome shares it) of Microsoft Edge.

    The Startup Boost feature did create a new instance of Microsoft Edge after its closure with the command-line "[..]\msedge.exe --no-startup-window --win-session-start  /prefetch:5". The Background mode does literally what it should do, keeping running the process in the background.

    To disable Startup Boost feature, you can disable StartupBoostEnabled policy.

    To disable the Background Mode, you should disable BackgroundModeEnabled policy for Edge, and the same policy for Chrome.

    All these settings can be configured in registry editor if you are not familiar with Group Policy Objects configuration.

    On the other hand, it seems you are not running Kiosk mode with the recommended command line option --edge-kiosk-type=fullscreen (if you need fullscreen). If the solution above does not fix this problem, try using the command line option instead.


    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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.