How to bring a GUI running as service in background to front on login?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mbmccormick
    New Member
    • Feb 2008
    • 21

    How to bring a GUI running as service in background to front on login?

    I have a .NET Windows Form application running in the background as a service on a server under the SYSTEM user account. Is there any way for me to view the GUI of this application (bring it to the front) when a user logs in to the server? (either programatically or something I can do in Windows)

    Thanks.
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    My guess would be to add to windows start up menu and load, but not my area so...

    Comment

    • mbmccormick
      New Member
      • Feb 2008
      • 21

      #3
      Originally posted by kenobewan
      My guess would be to add to windows start up menu and load, but not my area so...
      Right. The application is already running (because it starts at boot), and I need to bring that GUI (and task tray icon, because it has that) to the active display (console session) when a user logs in.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Have your service listen for a special message, then have a small program that will be launched when the user logs in that sends ou this message. When the message is received, the window is shown?

        Comment

        • mbmccormick
          New Member
          • Feb 2008
          • 21

          #5
          Originally posted by Plater
          Have your service listen for a special message, then have a small program that will be launched when the user logs in that sends ou this message. When the message is received, the window is shown?
          I see what your saying. Sort of like the ServiceControll er object. I don't really want to rework this whole program to incorporate this object.

          I guess I should rephrase this question... Is there a tool or command that I can use to bring an application (not a service) that is running in the background to the active display (i.e. make it visible) in Windows?

          Comment

          • Shashi Sadasivan
            Recognized Expert Top Contributor
            • Aug 2007
            • 1435

            #6
            A windows service is not intended to use GUI, and if it does have GUI components then there is a waay to allow the GUI to be displayed,
            its somethere from the services -> rightclick, and some property is to be set.

            However that compromises some security of the OS, not exactly sure of that.

            But the way to show a UI , is to create a windows applications, and start it up when the service raises an event.

            Comment

            • krishnabhargav
              New Member
              • Feb 2008
              • 24

              #7
              Originally posted by Shashi Sadasivan
              A windows service is not intended to use GUI, and if it does have GUI components then there is a waay to allow the GUI to be displayed,
              its somethere from the services -> rightclick, and some property is to be set.

              However that compromises some security of the OS, not exactly sure of that.

              But the way to show a UI , is to create a windows applications, and start it up when the service raises an event.

              It does not work that way.... I remember doing a Windows Service Project where I launched a Notepad process. But guess what, Notepad would run and you can see it appear in the taskmanager, but you would not be able to see the GUI.

              It was almost 3 years back and I do not remember exactly. But here is what I think that would work.

              Go to Services->Select your service and go to properties->Log on tab.

              Check "Allow this service to interact with Desktop".

              This should do the trick and when you make a Process.Start() like calls to launch a GUI apps, then they would show up. with this checkbox unchecked, your GUI would not be seen.

              Anyway I do not exactly remember how to do it within the service installer. I will let you know in case I figure it out.

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                If I had to guess, the reason you never saw the GUI for your notepad before, was that it was as a different user then the currently logged on one. (If you look in taskmanager you can add the column that says what user the process belongs too)
                But I could be wrong on that, and it could just be the way services work anyway.

                Comment

                • krishnabhargav
                  New Member
                  • Feb 2008
                  • 24

                  #9
                  Originally posted by Plater
                  If I had to guess, the reason you never saw the GUI for your notepad before, was that it was as a different user then the currently logged on one. (If you look in taskmanager you can add the column that says what user the process belongs too)
                  But I could be wrong on that, and it could just be the way services work anyway.
                  hmm...it was long back so i am not too sure. But i think the user account was all right. like i said there is an option that enables your service to interact with the desktop,

                  Comment

                  • mbmccormick
                    New Member
                    • Feb 2008
                    • 21

                    #10
                    Thank you Shashi Sadasivan and krishnabhargav! This fixed my problem, and I can now see my service. The "Allow this service to interact with the desktop" did it for me. Thanks again!

                    I have one last question... I can login and see my GUI (which is great), but now whenever I logout the service gets stopped. What can I do, either by modifying the code in my VB .NET application or as a setting in Windows or on the service to avoid this problem?

                    Comment

                    • krishnabhargav
                      New Member
                      • Feb 2008
                      • 24

                      #11
                      Originally posted by mbmccormick
                      Thank you Shashi Sadasivan and krishnabhargav! This fixed my problem, and I can now see my service. The "Allow this service to interact with the desktop" did it for me. Thanks again!

                      I have one last question... I can login and see my GUI (which is great), but now whenever I logout the service gets stopped. What can I do, either by modifying the code in my VB .NET application or as a setting in Windows or on the service to avoid this problem?
                      Like I said earlier, been a really long time since i did any win daemons.

                      anyway, try to run the service on a super user account, like other windows services which (much to our dismay) keeps running even if u log out

                      Comment

                      • mbmccormick
                        New Member
                        • Feb 2008
                        • 21

                        #12
                        I've moved this to: http://www.thescripts. com/forum/showthread.php? p=3063414#post3 063414

                        Comment

                        Working...