0

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.

Gautam
  • 1,728
  • 8
  • 32
  • 67

1 Answers1

1

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

Click here to know more