ipoh
ipoh

Reputation: 181

Running Windows Service in Foreground

I have a bat file which is installed as a service. I can run the service on a remote box. This service needs to launch another application. The launched application needs to be visible(run in foreground). Currently the launched application is running in background as the windows service is running in background. How can i make the windows service or both the windows service and the application that it launches run in foreground? I intend to manage the service with the ServiceController class in C#.

Upvotes: 2

Views: 3970

Answers (2)

Lex Li
Lex Li

Reputation: 63289

A proper approach is to launch the second application in the user's session, while your Windows service app always runs in session 0.

The approach has been part of my discussion with @RaheelKhan under this thread,

How reliable is adding an application manifest to ensure elevated privileges across windows xp, vista and 7?

It requires proper understanding of Windows sessions, session isolation, and platform invoke.

Upvotes: 0

Paul Farry
Paul Farry

Reputation: 4768

I think you should probably read

http://asprosys.blogspot.com.au/2009/03/allow-service-to-interact-with-desktop.html

Making a service to just launch another app is a real security issue, what if your other app gets replaced with something else do you have all the checks in your Service to ensure your app is the app you think it is.

Upvotes: 1

Related Questions