Hi all,
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 7 1220
"Ahmed Perlom" <pe****@hotmail.com> wrote in message
news:Oc**************@TK2MSFTNGP15.phx.gbl...
| Hi all,
|
|
|
| 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.
Thanks of your reply. The idea is that the windows service would monitor the
run of that application. If the application halts, or of there is an update,
the service would ask all instances of the application to stop (assuming
multiple apps are running for each user session), then ask them to -restart
again. So the service has to be in a global location monitoring whenever
users log on/off. The other tough side is that it is the current design of
the solutions by the architect and I just joined in, not much I can do ;)
Please let me know about the hard and insecure way.
Thanx
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:eF**************@TK2MSFTNGP15.phx.gbl... "Ahmed Perlom" <pe****@hotmail.com> wrote in message news:Oc**************@TK2MSFTNGP15.phx.gbl... | Hi all, | | | | 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.
Make sure your service is enabled to interact with the active desktop - if
it isn't then the GUI portion may run on a desktop that is not visible to
the logged on user.
"Ahmed Perlom" <pe****@hotmail.com> wrote in message
news:Oc**************@TK2MSFTNGP15.phx.gbl... Hi all, 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
The OP is not talking about a Service with a GUI portion, he wants to start
another GUI style application from a service.
Note also that enabling a service to interact with a desktop won't work any
longer in VISTA and beyond.
Willy.
"David Levine" <Sn*************************@wi.rr.com> wrote in message
news:uP**************@tk2msftngp13.phx.gbl...
| Make sure your service is enabled to interact with the active desktop - if
| it isn't then the GUI portion may run on a desktop that is not visible to
| the logged on user.
|
|
| "Ahmed Perlom" <pe****@hotmail.com> wrote in message
| news:Oc**************@TK2MSFTNGP15.phx.gbl...
| > Hi all,
| >
| >
| >
| > 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
| >
| >
|
|
I don't get it really, you are talking about multiple applications (Windows
Apps.) you want to start, stop, restart etc. What's the interactive user's
role here? Anyway, what you are trying to achieve is exactly what MSFT is
trying to prevent by all means, and is nearly impossible to make it secure
and robust. Note also that nothing in the framework will help you with this
either, you will have to PInvoke all Win32 API's and make sure you don't
forget any.
Before you go, you should have a good understanding of:
1. Windows desktops, window stations, how they interact with each other and
how they relate to the applications and their threads using these secured
executive objects. Please consult the MSDN docs and read as much as you can
about Desktops and WinStations (search MSDN for About Window Stations and
Desktops).
2. The security context of the user running as a service (the service
account) and the context of the application launched by such a service.
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" <pe****@hotmail.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...
| Thanks of your reply. The idea is that the windows service would monitor
the
| run of that application. If the application halts, or of there is an
update,
| the service would ask all instances of the application to stop (assuming
| multiple apps are running for each user session), then ask them
to -restart
| again. So the service has to be in a global location monitoring whenever
| users log on/off. The other tough side is that it is the current design
of
| the solutions by the architect and I just joined in, not much I can do ;)
| Please let me know about the hard and insecure way.
|
| Thanx
|
|
|
|
| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
| news:eF**************@TK2MSFTNGP15.phx.gbl...
| >
| > "Ahmed Perlom" <pe****@hotmail.com> wrote in message
| > news:Oc**************@TK2MSFTNGP15.phx.gbl...
| > | Hi all,
| > |
| > |
| > |
| > | 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.
| >
| >
|
|
I gotta agree with Willy on this one. Using a service like this is not a
good approach.
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]" <wi*************@telenet.be> wrote in message
news:em*************@TK2MSFTNGP10.phx.gbl... The OP is not talking about a Service with a GUI portion, he wants to start another GUI style application from a service. Note also that enabling a service to interact with a desktop won't work any longer in VISTA and beyond. Willy.
"David Levine" <Sn*************************@wi.rr.com> wrote in message news:uP**************@tk2msftngp13.phx.gbl... | Make sure your service is enabled to interact with the active desktop - if | it isn't then the GUI portion may run on a desktop that is not visible to | the logged on user. | | | "Ahmed Perlom" <pe****@hotmail.com> wrote in message | news:Oc**************@TK2MSFTNGP15.phx.gbl... | > Hi all, | > | > | > | > 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 | > | > | |
the way I have done this in the past is to have the service modify a
registry setting / file / etc when it needs to update teh UI app.
Have your UI application periodically check the registry key - if it is set,
then have the UI app shell another (very small, generic) app that takes an
exe as a command line parameter. The UI app then ends.
The 2nd app has a timer that wait 10 secs (to allow the first app to end)
and then shells the command line parameter passed - which is the name of the
first app to be restarted.
Consideration must be given for the case when the user is currently in the
middle of doing something - if the app dies then you shall not thanked.
cheers
Terry
"Ahmed Perlom" <pe****@hotmail.com> wrote in message
news:Oc**************@TK2MSFTNGP15.phx.gbl... Hi all, 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Glenn |
last post by:
I have used this code successfully in a form application.
I tried to add the same code in a service and have not
been able to get the application to start. I have the
service starting with a local...
|
by: karl |
last post by:
I have a windows service that kicks off a 'monitor' thread which in
turn kicks off 4 additional threads. These 4 threads basically are
listen on a designated socket and report back any errors...
|
by: Razzie |
last post by:
Hey all,
I wrote a Windows Service. When I test it on my developement machine (winXP)
it works fine. It starts ok, never crashes, etc.
When I install the service on another machine (win2000) it...
|
by: Kristof Despiere |
last post by:
Suppose you have one domain, filled with a couple of users. What needs to be
done now is I need to start a windows application from a webform by pressing
a button on the webform (for example).
...
|
by: tshad |
last post by:
I have a Windows Service I created that just sets a timer and writes to
EventLog every 10 seconds.
It installed fine and it actually starts. But it says it doesn't. The
progress bar shows the...
|
by: hogcods |
last post by:
I'm having a strange problem with a service I developed. After installing the service on the target machine, I'm trying to start it using the Services admin window. I get the "Windows is starting"...
|
by: Johnny Fugazzi |
last post by:
OK, I created my handy little windows service and created an MSI installer
using the Deployment tool in VS.net with Custom Actions according to the
msdn help.
Worked great, with one little...
|
by: Arnie |
last post by:
We're using the ServiceController class provided by the .NET Framework,
programming in C#. We are using the Start() method to start a service from
another service. This works fine most of the...
|
by: Benzi Eilon |
last post by:
I have written a C# application which should run as a Windows
Service. I must avoid having multiple instances of the application
on one machine so I inserted the following code at the beginning
of...
|
by: eliasen |
last post by:
Hi
I have created a Windows Service using C# and .NET2.0. The service is
quite simple - right now it doesn't do anything except throwing an
exception in the OnStart method. It used to something...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |