Can a Windows Service start a process that has UI stuff in it?

Posted on 2006-04-30
Last Modified: 2007-11-27
The service is started in the LocalSystem, I've got it controlling some processes which start ok, and show up in task manager - but none of their UI appears (notifyIcon, Form, MessageBox, etc).

Is this because it's running as SYSTEM? I tried running it as User, but when I tried to install the service it asked for my username password - which I entered correctly - but it rejected them.
Question by:salted
    LVL 37

    Expert Comment

    In order to have the UI stuff show up you would need to "Allow interaction with desktop" for the service, you can do this in the service properties (check box under the login info) ... This does however have some security implications and is generally frowned upon.

    If you are running GUI stuff in a service that GUI stuff should probably be in another app that communicates with the service as opposed to within the service itself.



    Author Comment

    > If you are running GUI stuff in a service that GUI stuff should probably be in another app that communicates with the service as opposed to within the service itself.

    That's what I'm trying to do :) I'm using the service to manage the processes, it's a server app so I need the service to make sure processes are running when they should be - would you say an app in startup would do this better? It just seemed perfect for a service. (All the service currently does is control the processes).
    LVL 37

    Accepted Solution

    it can work ... but keep in mind a service runs even when there are no logged on users etc.

    The processes you are creating sound like they may be better off as services themselves :)

    Author Comment

    Yes, the problem is that they are using the WebBrowser control for some web crawling stuff (I need mshtml's .InnerText property among others). And to run just one at once would take days, so if I put them in a service, the only option left would be multi-threading - but the WebBrowser control isn't thread-safe :(

    I only need the settings dialog and notify icon to be visible (which are already in their own app), so I guess I could stop the service launching this particular app, and instead add into startup - so it only actually shows when the server's administrator logs in.

    I'm going to do that - thanks for your help Greg.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now