CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 6 FirstFirst 123456 LastLast
Results 31 to 45 of 83
  1. #31
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: running a GUI program in the background

    Okay, it's time to return back to your original design. You say you run the program from your service. Windows Vista/7 service runs in a separate non-interactive session, so any process the service launches remains running in the session, which means no interaction with desktop. Unless you make it run interactive intentionally, which I guess you did not.

    What is the OS version you do that run in?

    If the OS is XP, do you instruct your service run interactive? If you do, remove the interactive flag.
    Best regards,
    Igor

  2. #32
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: running a GUI program in the background

    I wonder if the OP actually has a real service application or is running a pseudo service (like a console application)?

    @OP, can you answer if you have created a Windows service application, and if you have are you running it under the System account or under a user account?

    Btw, I ask because if you are using a real Windows Service application running under a Service account and it launches a Windows app, you will not see that app run in the logged on user's desktop regardless of whether you have set the app to be shown or not in the CreateProcess call.

  3. #33
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: running a GUI program in the background

    Quote Originally Posted by Arjay View Post
    Btw, I ask because if you are using a real Windows Service application running under a Service account and it launches a Windows app, you will not see that app run in the logged on user's desktop regardless of whether you have set the app to be shown or not in the CreateProcess call.
    Not exactly. I provided sample in the post where service is able to run app in the interactive user session. This is what generally I meant by saying "make it run interactive intentionally."
    Best regards,
    Igor

  4. #34
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: running a GUI program in the background

    Quote Originally Posted by Igor Vartanov View Post
    Not exactly. I provided sample in the post where service is able to run app in the interactive user session. This is what generally I meant by saying "make it run interactive intentionally."
    I'm aware of running a service interactively. Since that isn't a best practice and only works for the first logged on user, I'm kind of ignoring that special case.

    The bottom line is to use the Windows features as intended rather than doing some hack to get things to work (because as we all know, what works as a hack now, may not work in the next release of Windows).

    That being said, I don't mean to imply that you are suggesting any sort of hack.

  5. #35
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: running a GUI program in the background

    There's definitely some misunderstanding there. I told about running interactive process from non-interactive service. And I nevere recommended running services interacting with desktop directly in the same session & window station. I hoped for all the years we're on CG you know me better.
    Best regards,
    Igor

  6. #36
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: running a GUI program in the background

    Quote Originally Posted by Igor Vartanov View Post
    There's definitely some misunderstanding there. I told about running interactive process from non-interactive service. And I nevere recommended running services interacting with desktop directly in the same session & window station. I hoped for all the years we're on CG you know me better.
    I didn't mean to imply that you had, athough I must admit that my wording wasn't too clear.

  7. #37
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    i am using window7. i tried setting the service to interact with the desktop but that doesn't work either

  8. #38
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: running a GUI program in the background

    Quote Originally Posted by kw1991 View Post
    i am using window7. i tried setting the service to interact with the desktop but that doesn't work either
    What exactly "doesn't work"?
    And how did you try to "setting the service to interact with the desktop"?
    Victor Nijegorodov

  9. #39
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    What exactly "doesn't work"?
    when i run the service and check the processes that are running (by using task manager) I don't see the GUI program running
    And how did you try to "setting the service to interact with the desktop"?
    In the Service Management Console i changed the log on property to local system account and clicked the interact with desktop box

  10. #40
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: running a GUI program in the background

    Quote Originally Posted by kw1991 View Post
    i am using window7.
    If you really want to be helped, you should read and answer all the questions you've been asked in this thread, and be be more verbose in your explanations.

    Quote Originally Posted by kw1991 View Post
    i tried setting the service to interact with the desktop but that doesn't work either
    As far as I remember, you complained about program window showing in interactive desktop. So your try made no sense, as what you need is exactly opposite.
    Best regards,
    Igor

  11. #41
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    ok what questions still need answering? i am using Windows 7, i created a windows service application using c++ visual studio and it uses the local service account

  12. #42
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: running a GUI program in the background

    Then your problem is the program that you launch from your service. And I really doubt you'd be able to play the hook game in this case.

    See the sample I attach here. Make it, do setup and try test run. The teast.exe process must be present in the list, and its session must be 0 (non-interactive service session).

    Then change the service source code to launch you program and see if it starts in session 0. Please remember, we're talking about Windows 7. When you get what you want in Win7, we can start curing your problem in XP.
    Attached Files Attached Files
    Best regards,
    Igor

  13. #43
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    ok thanks for the code. how do i install the service so it appears in the Service Management Console?

  14. #44
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: running a GUI program in the background

    Run setup.bat, as I said above.
    Best regards,
    Igor

  15. #45
    Join Date
    Mar 2013
    Posts
    30

    Re: running a GUI program in the background

    ok i tried that and got this message:
    [SC] StartService FAILED 2:
    The system cannot find the file specified.

Page 3 of 6 FirstFirst 123456 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured