1

I want to pop a browser with a given url from within a windows service. Like so:

System.Diagnostics.Process.Start("http://www.venganza.org/");

Works fine when running in a console but not from within the service. No error messages, no exceptions, the Process.Start() command just seem to do nothing. It smells of some security issue, maybe something with the service properties and/or logon options? Annoying stuff this... Anybody? (Oh, and on windows 7/.NET framework 3.5.)

BaBu
  • 1,923
  • 2
  • 16
  • 27
  • possible duplicate of http://stackoverflow.com/questions/2330519/launching-web-browser-from-windows-service – Rowland Shaw Apr 12 '10 at 12:24
  • Similar question to this one, http://stackoverflow.com/questions/2330519/launching-web-browser-from-windows-service – Jonathan Apr 12 '10 at 12:23

3 Answers3

3

A service should never pop up anything to the user. Don't do this with a service.

You will problably need elevated rights to do this aswell. You will have to sign in as the user.

Even if you manage to do this, don't. This is not what services is ment for and it is really bad practise. If you really want someting to pop up, have a seperate process instead.

Oskar Kjellin
  • 21,280
  • 10
  • 54
  • 93
0

It is popping up, but on the Window Station associated with the service.

I would suggest that you tweak your design such that your service doesn't need to interact in this manner. There are ways to get it to appear on an interactive desktop (you'd have to cope with issues such as impersonating the relevant user, targeting the correct desktop if nobody is logged on or if more than one person is logged on, etc.)

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • And the WindowStation associated with a service is typically not interactive, see http://msdn.microsoft.com/en-us/library/ms687105%28VS.85%29.aspx. And also don't forget that there might be several user sessions on a machine. How to decide which user should see the window? – Dirk Vollmar Apr 12 '10 at 12:25
  • @0xA3 That's why I said about coping with those issues if you really wanted to go down this route. – Rowland Shaw Apr 12 '10 at 12:32
0

Just on a side note Windows services aren't built for interactivity. They are used to process behind-the-scenes type stuff. However, have you tried enabling the Interact with Desktop option on the service itself?

James
  • 80,725
  • 18
  • 167
  • 237
  • Oh yes, I've tried the 'interact with desktop' option. Didn't work. I've come to agree that popping gui from a service is a bad idea in the first place. But then a new question arises: What is the 'interact with desktop' option for? – BaBu Apr 13 '10 at 10:36
  • I believe it is *technically* for testing as it does allow services to interact with GUI applications. Perhaps a console application is not considered a *GUI* to a service? Try it with a forms application just for clarity. – James Apr 13 '10 at 13:16