1

(c#, .net framework 2.0 desired)

Hello.

This is a pratical and technical question... you have been warned. :)

I have a windows service, which requires each user to provide a login to an online service. Lets imagine we have two users a and b.

a runs the installation process, which at the end asks for the login credentials for the online serive. Stores it locally and ding, when the service starts it knows the user.

b comes along, logs off a, logs themself on. The service notices a new user, checks to see if it has login details, figures out it doesn't.

I thought I could use Process.Start to fire up a windows app. nope. So I googled and it looks like if I write a bunch of code (shown here as CreateProcessAsUser ) it's possible, but not advised to do this.

So... what should I do? Happy for any technical or pratical solutions.

philbird
  • 789
  • 1
  • 8
  • 15
  • I use CreateProcessAsUser including on Windows 7, and it works to do what you are trying to do. – Ed Bayiates Aug 08 '11 at 21:21
  • I am wondering if there's no some way to create a "first run" application for each user which asks them to logon the first time they login and then no subsquently? – philbird Aug 09 '11 at 07:25
  • You can use the Run regkey for that or the startup folder, but users often clean those out. – Ed Bayiates Aug 09 '11 at 12:51

1 Answers1

1

Showing any kind of user interface from within a service is not only discouraged, but even explicitly prevented in some Windows platforms (windows Server 2008 comes to my mind).
The common approach for this task is to develop two independet modules, a Windows Service and a GUI application that communicates with the services using one of the many IPC schemes available, depending on the complexity of the data to be transfered. A loopback WCF (Web Service) for example could be a good approach.
If implemented properly, this solution will also work in complex scenarios like multiple terminal services sessions.

yms
  • 10,361
  • 3
  • 38
  • 68