Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / April 2006

Tip: Looking for answers? Try searching our database.

ServiceProcess output to screen

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ThePinkPanther - 23 Apr 2006 06:19 GMT
Hello
Hopefully it's the right place to ask this question.
Let's say i'm building a program which will run as a Service in the
background using
System.ServiceProcess , And i want it to output data to a user connected to
the machine
(show him a messagebox and so on).
How am i to do that?

Thank you
Stuart Nathan - 23 Apr 2006 12:04 GMT
You can't do it directly.
What I did was to write a simple application with a message screen, and used
the command line to send the message.
I then added the code in my service:-
Dim prc as new process
prc.startinfo.filename="??"
prc.startinfo.arguments=message
prc.start

However you have to also ensure that your service can interface with
desktop.
Computer Management > Service> Properties
Mehdi - 23 Apr 2006 14:00 GMT
> You can't do it directly.
> What I did was to write a simple application with a message screen, and used
> the command line to send the message.
[...]
> However you have to also ensure that your service can interface with
> desktop.
> Computer Management > Service> Properties

No offense but this is a terribly bad idea. For 3 reasons:

1) nothing garantees that there will be an interactive user logged in when
the windows service will launch the display application. If nobody is
logged in, the application will be stuck in some invisible desktop with no
way for anybody to either see it or close it.

2) Launching an application from a Windows Service means that the
application will run under the user account of the Windows service (and not
under the user account of the user that might be logged in at the time).
This user acount is often Local System which is, in some ways, as powerfull
and even more powerfull than the Administrator account. Using your
application and some well known exploits, it's gonna be child play for
hackers to gain administrator priviledges on the machines. BANG, you're
dead.

3) AFAIK, interactive windows services won't be allowed anymore under
Windows Vista so this method won't work at all under Vista

The only way for a service to interact with an interactive user is to
develop a normal windows application for this purpose, set it to start
automatically when a user logs in and communicate with this application
from your windows service using some kind of IPC. This could be sockets,
shared memory, .NET remoting or any other way you see fit.

Note that if all you want is to display a message box, you could do that
using the MessageBox.Show method directly from your service using the
MessageBoxOptions.ServiceNotification parameter. You should be well aware
of what this method implies before using it though (in particular this will
block the caller until the user, which might not be there, dismisses it).
See the last part of this article for more details:
http://pluralsight.com/wiki/default.aspx/Keith.GuideBook/HowToDisplayAUserInterf
aceFromADaemon.html


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.