Gautam
Gautam

Reputation: 1740

Windows Service not starting chrome with Process.Start()

I have written a windows service that is supposed to run a chrome instance. how ever on attaching the service to the process I am able to hit the breakpoint to Process.Start but it does not opens the chrome. also I do not get any error.

can anyone help me here.

protected override void OnStart(string[] args)
        {
            var timer = new Timer(5000);
            timer.Elapsed += TimerElapsed;

            timer.Start();
        }

 void TimerElapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                var processes = Process.GetProcessesByName("Chrome");


                var found = false;
                foreach (var process in processes)
                {
                    if (process.MainWindowTitle.StartsWith("title"))
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    var process = Process.Start("Chrome", "http://localhost");
                   }
            }
            catch (Exception ex)
            { 

            }
        }

If I create a windows application for the same then it works fine.

Upvotes: 0

Views: 998

Answers (1)

user1755942
user1755942

Reputation:

due to session 0 isolation I guess this is not a good idea to proceed upon..

Click here to know more

Upvotes: 1

Related Questions