473,883 Members | 2,332 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Windows Service

Hello --

I plan on writing a C# service using VS2005.

If I want my service to have a tray icon, is this typically done from within
my service or do/should I create a controller application and have that run
separately from my service?
Jun 27 '08 #1
9 2346
dm3281 wrote:
If I want my service to have a tray icon, is this typically done from
within my service or do/should I create a controller application and
have that run separately from my service?
The latter. Services should not interact with any user, and indeed by
default they cannot (they run in a separate non-interactive window station).

Services typically run with elevated privileges, so design the interface
between your service and the controller application carefully. In
particular, the controller application should not enable a lower-privileged
user to compromise the system by interacting with the service in an
uncontrolled manner.

Also, consider the idea of having a tray icon in the first place carefully.
Is your service really both important enough to warrant an icon *and* so
often in need of adjustment that you need a permanently accessible icon for
it? A simple on-demand application may do just as well.

I currently have two services on my system that work with tray icons, and
I'm happy that Windows allows me to hide these icons, because I sure never
need them... Only one of these offers me the option of removing the tray
icon, but this is only good for the current session -- at the next logon it
will cheerfully pop up again. Take care not to bother the user with things
they're not interested in.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #2

"dm3281" <dm****@nospam. netwrote in message
news:6D******** *************** ***********@mic rosoft.com...
Hello --

I plan on writing a C# service using VS2005.

If I want my service to have a tray icon, is this typically done from
within my service or do/should I create a controller application and have
that run separately from my service?
Sure, you can have a exe application that sits in the job trey that controls
the Windows service. About the only thing the program should be doing is
starting or stopping the service.

Jun 27 '08 #3
you can create tray icon from your service or you can create a seperate exe
that integrate/works with your service.
Regards,
Mudassar Hassan
http://mudassarhassan.spaces.live.com/
"Mr. Arnold" wrote:
>
"dm3281" <dm****@nospam. netwrote in message
news:6D******** *************** ***********@mic rosoft.com...
Hello --

I plan on writing a C# service using VS2005.

If I want my service to have a tray icon, is this typically done from
within my service or do/should I create a controller application and have
that run separately from my service?

Sure, you can have a exe application that sits in the job trey that controls
the Windows service. About the only thing the program should be doing is
starting or stopping the service.

Jun 27 '08 #4
Mudassar Hassan wrote:
you can create tray icon from your service or you can create a seperate exe
that integrate/works with your service.
I reiterate that services should not and by default cannot interact with
users. From Windows Vista onwards, there is not even a way to allow it
anyway as there was with previous versions of Windows
(http://msdn.microsoft.com/library/bb126610.aspx).

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #5

"Jeroen Mostert" <jm******@xs4al l.nlwrote in message
news:48******** *************** @news.xs4all.nl ...
Mudassar Hassan wrote:
>you can create tray icon from your service or you can create a seperate
exe that integrate/works with your service.
I reiterate that services should not and by default cannot interact with
users. From Windows Vista onwards, there is not even a way to allow it
anyway as there was with previous versions of Windows
(http://msdn.microsoft.com/library/bb126610.aspx).
You want to show some kind of standard here to say that a Windows Service
should not interact with the user. Where does it say that? I am going to
assume that you are not talking about an UI exe in communications with a
Windows Service.

And what is that link suppose to be showing about Vista?

Jun 27 '08 #6
Mr. Arnold wrote:
>
"Jeroen Mostert" <jm******@xs4al l.nlwrote in message
news:48******** *************** @news.xs4all.nl ...
>Mudassar Hassan wrote:
>>you can create tray icon from your service or you can create a
seperate exe that integrate/works with your service.
I reiterate that services should not and by default cannot interact
with users. From Windows Vista onwards, there is not even a way to
allow it anyway as there was with previous versions of Windows
(http://msdn.microsoft.com/library/bb126610.aspx).

You want to show some kind of standard here to say that a Windows
Service should not interact with the user. Where does it say that?
Is http://support.microsoft.com/kb/327618 good enough?
I am going to assume that you are not talking about an UI exe in
communications with a Windows Service.

And what is that link suppose to be showing about Vista?
Ha, good catch. I managed to copy the wrong link somehow... The linked
article is interesting if you're interested in Domain-Specific Languages,
but won't tell you much about Vista and interactive services. I wanted this
one: http://msdn.microsoft.com/library/ms683502.aspx

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #7

"Jeroen Mostert" <jm******@xs4al l.nlwrote in message
news:48******** *************** @news.xs4all.nl ...
Mr. Arnold wrote:
>>
"Jeroen Mostert" <jm******@xs4al l.nlwrote in message
news:48******* *************** *@news.xs4all.n l...
>>Mudassar Hassan wrote:
you can create tray icon from your service or you can create a seperate
exe that integrate/works with your service.

I reiterate that services should not and by default cannot interact with
users. From Windows Vista onwards, there is not even a way to allow it
anyway as there was with previous versions of Windows
(http://msdn.microsoft.com/library/bb126610.aspx).

You want to show some kind of standard here to say that a Windows Service
should not interact with the user. Where does it say that?

Is http://support.microsoft.com/kb/327618 good enough?
That link doesn't indicate what you are talking, and the only thing it
indicates is the statement below, which a Windows service doesn't have to
run with System rights.

<copied>

Important We strongly recommend that services do not run as interactive
services if the services run in an elevated security context such as SYSTEM.

<copied>

Your advise doesn't seem to be correct for all situations here.

Heck, even in the MCSD MSPress Certification book for Windows desktop
solutions in C# and VB back for VS 2003 had a whole application exercise
that was using a Windows form base solution that was in communications with
a Windows service on the backend and passing data to/from each other.
>
>I am going to assume that you are not talking about an UI exe in
communicatio ns with a Windows Service.

And what is that link suppose to be showing about Vista?
Ha, good catch. I managed to copy the wrong link somehow... The linked
article is interesting if you're interested in Domain-Specific Languages,
but won't tell you much about Vista and interactive services. I wanted
this one: http://msdn.microsoft.com/library/ms683502.aspx
I don't know man. If I wanted to communicate interactively with a Windows
service from a Windows desktop solution on Vista, I would be using .Net
Remoting, MSMQ, or (WCF using a Named Pipe or MSMQ) locally if I had to go
that route.

You can also use this too on Vista for cross process communications,
locally.

http://www.codeproject.com/KB/dotnet/XDMessaging.aspx

Maybe we are talking two different things in going into communications with
a Windows service from a desktop solution interactively.

Jun 27 '08 #8
Mr. Arnold wrote:
>
"Jeroen Mostert" <jm******@xs4al l.nlwrote in message
news:48******** *************** @news.xs4all.nl ...
>Mr. Arnold wrote:
>>>
"Jeroen Mostert" <jm******@xs4al l.nlwrote in message
news:48****** *************** **@news.xs4all. nl...
Mudassar Hassan wrote:
you can create tray icon from your service or you can create a
seperate exe that integrate/works with your service.
>
I reiterate that services should not and by default cannot interact
with users. From Windows Vista onwards, there is not even a way to
allow it anyway as there was with previous versions of Windows
(http://msdn.microsoft.com/library/bb126610.aspx).
You want to show some kind of standard here to say that a Windows
Service should not interact with the user. Where does it say that?

Is http://support.microsoft.com/kb/327618 good enough?

That link doesn't indicate what you are talking, and the only thing it
indicates is the statement below, which a Windows service doesn't have
to run with System rights.

<copied>

Important We strongly recommend that services do not run as interactive
services if the services run in an elevated security context such as
SYSTEM.

<copied>

Your advise doesn't seem to be correct for all situations here.
A service is an always-on, background process. For this reason alone it's
fundamentally flawed to have it interact with the desktop: there need never
be anyone sitting in front of the computer, so what exactly is the service
trying to achieve with that?

Second, services usually run with elevated credentials. It needn't be SYSTEM
-- that's just the worst-case scenario. The point is that a service will
usually run under credentials that allow it to do things any other logged-on
user can't do directly, as that's often the point of having a service in the
first place (though admittedly not always). For example, SQL Server can run
under limited credentials, but even in this setup those are usually the only
credentials with file system access to the database, for obvious reasons.

All interactive services open themselves up to shatter attacks, and there's
not much they can do against it. It's a security vulnerability, which is why
Microsoft closed it off altogether.
Heck, even in the MCSD MSPress Certification book for Windows desktop
solutions in C# and VB back for VS 2003 had a whole application
exercise that was using a Windows form base solution that was in
communications with a Windows service on the backend and passing data
to/from each other.
And there's nothing wrong with that -- I assume it wasn't the *service* that
was displaying UI.
I don't know man. If I wanted to communicate interactively with a
Windows service from a Windows desktop solution on Vista, I would be
using .Net Remoting, MSMQ, or (WCF using a Named Pipe or MSMQ) locally
if I had to go that route.
Sure, all fine solutions. All these channels are securable and provide
isolation.
You can also use this too on Vista for cross process communications,
locally.

http://www.codeproject.com/KB/dotnet/XDMessaging.aspx

Maybe we are talking two different things in going into communications
with a Windows service from a desktop solution interactively.
Let's be clear here: there's nothing wrong with communicating with a service
in a cross-process scenario. What's strongly discouraged is your *service*
interacting with the desktop *directly*.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #9

"Jeroen Mostert" <jm******@xs4al l.nlwrote in message
news:48******** *************** @news.xs4all.nl ...
Mr. Arnold wrote:
>>
Maybe we are talking two different things in going into communications
with a Windows service from a desktop solution interactively.
Let's be clear here: there's nothing wrong with communicating with a
service in a cross-process scenario. What's strongly discouraged is your
*service* interacting with the desktop *directly*.
All my experience with Windows services have been with unattended execution
for backend processing. in a queuing scenario.

If I had to go into communications with a Windows Service from the UI, then
it would be based on what I have discussed with you, which is program and
cross-process isolation.

Maybe, the OP will read all of the posts between you and I and has learned
something.

You take care now, yeah hear.
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2272
by: Michael Riggio | last post by:
Is there a way to have a windows service instantiate a class that is a web service, which will then be accessible to clients via HTTP? Thanks, -Mike
1
5697
by: Artur Kowalski | last post by:
I have a NotifyIcon in my Windows Service project and I am trying to add a ContextMenu to this NotifyIcon or use some of the mouse events. Everything isn't working. I think so base class of the service System.ServiceProcess.ServiceBase don't catchWindows messages like mouse or timer messages. Any Idea? Thanks,
3
5145
by: belgiozen | last post by:
Hi, I have a working windows service,it is looking for files on the disk and when some of the files are cupdated it calls an executable. But it takes a lot of time(about 10 minutes) to run the executable.So while that executable is running,if I try to stop the windows service while the executable(MYPROGRAM.EXE) is running,it will wait for a time(about 20 seconds) for the main windows thread to abort.If it does not finish its work, the...
2
2943
by: Neslihan ERDEM | last post by:
Every body Hi first of all I say Why do I need Windows Service / Every Day I create XML file . I writed a XML web service And .I join this servis Windows service. I create Windows Service that I call method XML Web Service . My Problem I generate Windows Service but I want this service always run . But I dont make it
9
7277
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service stopping. Please advise how to stop the service. Thanks, SP
3
2204
by: Nathan Kovac | last post by:
I have a feeling I am missing something simple, but I just can't find it. Perhaps someone can give me a lead on where to look. I will describe the issue then post my code to the web service. My issue is simply getting timers to work. I have a DatabaseManager.DataManagerFacade which contains a timer. Every 6 seconds it updates stock data using an online webservice. I wrote have 2 possible startup projects to make the service work. One...
3
3694
by: Doug Bailey | last post by:
I am trying to control a Windows Service via a Web Service interface. (I am developing in .NET2003) I am using the ServiceController object which allows me to read the state of the services with no problems. However, I am not able to start or stop the service unless I go through the process of impersonating an administrative user. (See MSDN KB 306158) Since it appears to be a privilege issue, I set the folders in IIS holding the Web...
2
6905
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app (which is the UI used to adjust the actions taken by, and the schedule of the service), then a privileged user thread should be used in the UI - no service required. But... "A windows service enables the creation of long-running executable
5
4268
by: sonali_reddy123 | last post by:
Hello all, I am trying to develop an application which will run as a windows service. The application should have Normal options available with service like start, stop and pause but along with this I need an option to show the windows application which my service has started as a result of its invokation. So I have written a service control by adding a new project of type
5
3318
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
0
9953
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9799
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10868
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7984
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7137
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5808
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4231
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3242
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.