I am trying to start a windows application that has a GUI from a Windows
service written in .NET 2.0. I have been searching on this for few days now
with no avail. When using the System.Diagnostic.Process object to start the
application (i.e Notepad), the new app runs and it is listed on the task
manger list, but the GUI doesn't show up in the desktop of the current user.
I am aware windows service (either LocalSystem, NetworkService or
LocalService) all run in a sandbox environment. I have read some where
here that there is no secure and easy way to do this, however I have no
option really and I wonder if some one could give me some hints as how would
I do this in C# or VB.NET!!.
Thanks
Why do you need to start the UI application from a service in the first
place, there is no easy and secure way to do this. Why don't you start the
UI application when the user logs on, set a shortcut to the application in
the startup folder in the users profile and it will start whenever the user
logs on.
Willy.
Thanx
"Willy Denoyette [MVP]" <willy.d...@telenet.be> wrote in message
news:eFEywVtQ...@TK2MSFTNGP15.phx.gbl...
"Ahmed Perlom" <per...@hotmail.com> wrote in message
news:OcDp8CtQ...@TK2MSFTNGP15.phx.gbl...
"David Levine" <SnipHereDlevi...@wi.rr.com> wrote in message
news:uPB6ADyQ...@tk2msftngp13.phx.gbl...
When launching an application from a service you will need to:
- Create a logon session by calling Win32 LogonUser (via PInvoke) followed
by,
- a call to LoadUserProfile, this is needed to load it's environment and
profile, when done you can call...
- CreateProcessAsUser, here you need to fill the STARTUPINFO structure and
especially you need to set the 'lpdesktop' member to "Winsta0\Default", by
doing this you will start the application in the visible desktop. But there
is a catch, before you call CreateProcessAsUser you will need to add the
Logon users SID to the DACL of the Winsta0 object. Failing to do this will
prevent the launched application to use the visible desktop.
With any luck you'll have your application running, but, remember that you
have created a new logon session, that means that the application doesn't
run in the already existing interactive logon session, so each time you do
this you will create a new session and you will load the Users Registry Hive
and the environmat block into that session as HKCU, this will consume a lot
of resources when the previous session did not terminate.
Willy.
"Ahmed Perlom" <per...@hotmail.com> wrote in message
news:efCBVetQ...@TK2MSFTNGP09.phx.gbl...
A cleaner alternative would be to create a monitor application, that starts
with the user - and checks the running processes. That way, it runs and
dies with that users and has all the correct rights to operate in that users
context/desktop. One feature of this is that you can add a socket
server/listener to it that accepts remote commands, allowing the app to
spawn localised applications easily at the active desktop. It will only be
a handful of code lines to create.
--
Regards
John Timney
Microsoft MVP
"Willy Denoyette [MVP]" <willy.d...@telenet.be> wrote in message
news:em0wuG3...@TK2MSFTNGP10.phx.gbl...
"Ahmed Perlom" <per...@hotmail.com> wrote in message
news:OcDp8CtQ...@TK2MSFTNGP15.phx.gbl...