Search code examples
c#windows-servicessystem-tray

A Service Loaded exe can't 'System.Diagnostics.Process.Start' a URL?


I have a simple Tray icon program that opens a site using

System.Diagnostics.Process.Start("URL")

And it works fine independently, however when a service loads it, it gives a file not found exception when trying to open the URL, and after testing it can open normal extensions, e.g .txt (The service has desktop interaction enabled).


Solution

  • If you Process.Start a URL, it is loading a browser app, which isn't (for Vista/etc) going to display for a service (for the same reasons as your last question).

    If you want the app to interact with the user/desktop, it shouldn't be a service - it should simply run when the user logs in. Note that any child-process that your service spawns will also be in the service's session.

    If you just want to get data (through code) from the site, use WebClient etc.