NG wrote:
Hi All
I made a windows service in C#. Now I have a situation where I need
to invoke an exe with some UI. Assuming that the computer running
this service will always be logged in, can anyone please provide me a
sample code to invoke an exe from windows service in .net.
I tried a few methods that I found on the net but they seem to invoke
something in the background which actually does not work.
Any help is much appreciated.
The advice that Willy gives is spot on: you should not run a service to
interact with the desktop, nor should you even consider starting the UI
process from the service's account because the privileges of the
service's account will not be appropriate.
Instead, you should access the interactive user's window station and
make the thread impersonate the interactive user's account and then
create the process under that impersonation token. There is no simple
way to do that in .NET, in fact there is no simple way to do that in
Win32 either, although Keith Brown's excellent book "Programming Windows
Security" has all of the details.
A better solution is to create a separate process - possibly without a
UI, and only a notification icon in the tray - that is created at
interactive logon using the StartUp folder or the Run tregistry entry.
This would be a socket server, or a .NET remoting server and the service
can then send messages to this process to tell it to start processes.
Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm http://www.grimes.demon.co.uk/workshops/securityWS.htm