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.
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.
Re: running a GUI program in the background
Quote:
Originally Posted by
Arjay
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."
Re: running a GUI program in the background
Quote:
Originally Posted by
Igor Vartanov
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. :)
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. :)
Re: running a GUI program in the background
Quote:
Originally Posted by
Igor Vartanov
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.
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
Re: running a GUI program in the background
Quote:
Originally Posted by
kw1991
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"?
Re: running a GUI program in the background
Quote:
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
Quote:
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
Re: running a GUI program in the background
Quote:
Originally Posted by
kw1991
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
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.
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
1 Attachment(s)
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.
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?
Re: running a GUI program in the background
Run setup.bat, as I said above.
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.