How to start Edge browser from a Windows service

Zhu, Ligong 220 Reputation points
2024-09-06T18:47:32.75+00:00

Hi,

I need to create a new Windows service from where I can start an Edge instance using command line like this:

msedge.exe "http://localhost:9080/ebb/newIESession.action"Another thing the code does is to update some windows registry settings, which requires admin right.

I have put path to msedge.exe into system path.

It works well from command line. But after I created a window service to start this, no Edge can be started at all from the service.

I also tried to do this from Windows startup folder instead of using Windows service. The problem is that it only works when I have admin right.

Currently I use NSSM utility to create the new Windows service. It looks like everything installed and started correctly but no Edge window even showed up.

Can you tell me if it is possible to launch a new Edge browser from a Windows service or it can only perform background tasks without UI? If yes how to do it?

I appreciate your help.

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

Accepted answer
  1. Michael Taylor 54,316 Reputation points
    2024-09-09T13:58:42.78+00:00

    As stated in the other post, services run in isolation, independent of any user logged into the system. As such services cannot interact with or change user settings directly. Services are designed to provide functionality that runs independently of users. This is by design.

    If you need to modify user settings then look into using Group Policies if possible. There are lots of settings that are configurable there across a single computer or entire network. GPO is applied automatically and is the preferred approach. Most browsers, including Edge and Chrome, have GPOs for their settings. Not all settings are available though so you have to look through the docs for the settings you want.

    If a setting is not available in GPO but there is a registry entry to back it then you can set the registry via GPO as well. That is discussed here.

    If none of that works then the final resort would be to run a scheduled task using Task Scheduler. The task can run at user startup. Note that a task has to run under a user context and if it needs admin privileges then the user account must be an admin. That account is unrelated to the user who is logged into the system. For example the auto-update tools many programs use run as scheduled tasks with admin privileges. However the limitation on this is that a task's user context only has access to their user account so you couldn't, for example, have a task run as admin for a standard user account. That doesn't make sense anyway though.


1 additional answer

Sort by: Most helpful
  1. Michael Taylor 54,316 Reputation points
    2024-09-06T19:00:36+00:00

    Duplicate post

    0 comments No comments

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.