I have a VS 2005 Windows Service with a Installer project as part of my
solution. The Service installs fine but I can't seem to make either of
these work:
1. Have the service start after install
2. Have the service interact with the SysTray
In my ProjectInstalle r.vb
Private Sub ServiceInstalle r1_AfterInstall (ByVal sender As
System.Object, ByVal e As System.Configur ation.Install.I nstallEventArgs )
Handles ServiceInstalle r1.AfterInstall
Dim OS_EventLog As New MyStuff.Utiliti es.OperatingSys tem
Try
Dim KeyPath As String = "SYSTEM\Current ControlSet\Serv ices\" &
Me.ServiceInsta ller1.ServiceNa me
Dim ckey As RegistryKey =
Registry.LocalM achine.OpenSubK ey(KeyPath, True)
If ckey IsNot Nothing Then
ckey.SetValue(" Type", CInt(272))
End If
Catch ex As Exception
OS_EventLog.Cre ateEventLogEntr y("After Install Failed: " &
ex.ToString)
End Try
End Sub
This code works in the sense that the "Interacts with Desktop" checkbox IS
checked, but I still don't see my icon show in the systray. If I manually
go to my installed service and uncheck and then recheck and then start the
service again -- my icon WILL show in the systray. Is there more than one
reg entry to be set to make this work? Any hints or links where I can go to
make this do the above two tasks work reliably?
Thanks, Rob. 8 2671
I will assume that you have already read this .. http://support.microsoft.com/default...;EN-US;Q327618
The most successful methods I have seen are doing it through WMI http://www.codeproject.com/csharp/Cs...&select=675160
explains a method similar to what you are doing, there is a WMI example in
the feedback under "The right way to do it"
Cheers,
Greg
"Rob R. Ainscough" <ro*****@pacbel l.net> wrote in message
news:uh******** ******@TK2MSFTN GP05.phx.gbl... I have a VS 2005 Windows Service with a Installer project as part of my solution. The Service installs fine but I can't seem to make either of these work:
1. Have the service start after install 2. Have the service interact with the SysTray
In my ProjectInstalle r.vb
Private Sub ServiceInstalle r1_AfterInstall (ByVal sender As System.Object, ByVal e As System.Configur ation.Install.I nstallEventArgs ) Handles ServiceInstalle r1.AfterInstall
Dim OS_EventLog As New MyStuff.Utiliti es.OperatingSys tem
Try
Dim KeyPath As String = "SYSTEM\Current ControlSet\Serv ices\" & Me.ServiceInsta ller1.ServiceNa me Dim ckey As RegistryKey = Registry.LocalM achine.OpenSubK ey(KeyPath, True)
If ckey IsNot Nothing Then ckey.SetValue(" Type", CInt(272)) End If
Catch ex As Exception
OS_EventLog.Cre ateEventLogEntr y("After Install Failed: " & ex.ToString)
End Try
End Sub
This code works in the sense that the "Interacts with Desktop" checkbox IS checked, but I still don't see my icon show in the systray. If I manually go to my installed service and uncheck and then recheck and then start the service again -- my icon WILL show in the systray. Is there more than one reg entry to be set to make this work? Any hints or links where I can go to make this do the above two tasks work reliably?
Thanks, Rob.
Generally speaking, a service should not interact with the desktop.
You should write a "monitoring app" that communicates with the service
and that app would show your icon in the system tray. But, to
accomplish what you want, you will have to use the
System.ServiceP rocess.ServiceC ontroller to set the ServiceType property
using the InteractiveServ ice flag.
Since the service will start when the OS starts, no one will be logged
on at the time and there will be no desktop system tray to place the
icon on. How does your service know when someone has logged on?
If you intend your application to run on Windows Vista, then you cannot
allow the service to interact with the desktop as that won't be allowed
in Vista, so that's another reason not to do it in that manner.
If this is implemented due to security weakness in Vista, then I'd think
Microsoft need to address the issue rather than just apply blanket
restriction to valid uses of "Interact with Desktop" option currently
available to all services.
I seriously doubt Microsoft will remove the ability to "Interact with
Desktop" for the final release of Vista. I don't think Vista is even in
"release candidate" form yet anyway. Not to mention there is a long list of
main stream apps that have services that interact with the Desktop.
What exactly is a "monitoring app"? I mean you've basically just defined
what a service is, most services are monitoring/listeners sooo...
"Chris Dunaway" <du******@gmail .com> wrote in message
news:11******** **************@ v46g2000cwv.goo glegroups.com.. . Generally speaking, a service should not interact with the desktop. You should write a "monitoring app" that communicates with the service and that app would show your icon in the system tray. But, to accomplish what you want, you will have to use the System.ServiceP rocess.ServiceC ontroller to set the ServiceType property using the InteractiveServ ice flag.
Since the service will start when the OS starts, no one will be logged on at the time and there will be no desktop system tray to place the icon on. How does your service know when someone has logged on?
If you intend your application to run on Windows Vista, then you cannot allow the service to interact with the desktop as that won't be allowed in Vista, so that's another reason not to do it in that manner.
He means a normal application that represents the GUI aspects of the windows
service that in turn interacts with the windows service through another
means (such as remoting).
"Rob R. Ainscough" <ro*****@pacbel l.net> wrote in message
news:e$******** ******@TK2MSFTN GP02.phx.gbl... If this is implemented due to security weakness in Vista, then I'd think Microsoft need to address the issue rather than just apply blanket restriction to valid uses of "Interact with Desktop" option currently available to all services.
I seriously doubt Microsoft will remove the ability to "Interact with Desktop" for the final release of Vista. I don't think Vista is even in "release candidate" form yet anyway. Not to mention there is a long list of main stream apps that have services that interact with the Desktop.
What exactly is a "monitoring app"? I mean you've basically just defined what a service is, most services are monitoring/listeners sooo...
"Chris Dunaway" <du******@gmail .com> wrote in message news:11******** **************@ v46g2000cwv.goo glegroups.com.. . Generally speaking, a service should not interact with the desktop. You should write a "monitoring app" that communicates with the service and that app would show your icon in the system tray. But, to accomplish what you want, you will have to use the System.ServiceP rocess.ServiceC ontroller to set the ServiceType property using the InteractiveServ ice flag.
Since the service will start when the OS starts, no one will be logged on at the time and there will be no desktop system tray to place the icon on. How does your service know when someone has logged on?
If you intend your application to run on Windows Vista, then you cannot allow the service to interact with the desktop as that won't be allowed in Vista, so that's another reason not to do it in that manner.
Greg,
My service doesn't provide a "UI" in the sense that a user (or any user) can
interact with it. What I want to accomplish is simply provide the user with
some indication that a critical service they need is working or not (and
perhaps a message as to why not) -- if the service is not functioning (aka
some exception) the icon in the systray changes along with a message that
appears when they hover over the icon with the mouse cursor.
If this is Microsoft's stand, then they are getting lazy once again.
Blanket solutions to security problems limits functionality -- who wants to
live in a house with bars on the all the doors and windows which can't be
opened -- who's the real prisoner? MS need to do some work if they want to
get this implemented correctly rather than saying "you just can't do that
now because of our poor security model".
But thanks for the other link -- it worked well for me, looks like was using
the wrong event.
Rob.
"Greg Young" <Dr************ *@hotmail.com> wrote in message
news:%2******** *******@TK2MSFT NGP04.phx.gbl.. . I will assume that you have already read this .. http://support.microsoft.com/default...;EN-US;Q327618
The most successful methods I have seen are doing it through WMI
http://www.codeproject.com/csharp/Cs...&select=675160 explains a method similar to what you are doing, there is a WMI example in the feedback under "The right way to do it"
Cheers,
Greg "Rob R. Ainscough" <ro*****@pacbel l.net> wrote in message news:uh******** ******@TK2MSFTN GP05.phx.gbl...I have a VS 2005 Windows Service with a Installer project as part of my solution. The Service installs fine but I can't seem to make either of these work:
1. Have the service start after install 2. Have the service interact with the SysTray
In my ProjectInstalle r.vb
Private Sub ServiceInstalle r1_AfterInstall (ByVal sender As System.Object, ByVal e As System.Configur ation.Install.I nstallEventArgs ) Handles ServiceInstalle r1.AfterInstall
Dim OS_EventLog As New MyStuff.Utiliti es.OperatingSys tem
Try
Dim KeyPath As String = "SYSTEM\Current ControlSet\Serv ices\" & Me.ServiceInsta ller1.ServiceNa me Dim ckey As RegistryKey = Registry.LocalM achine.OpenSubK ey(KeyPath, True)
If ckey IsNot Nothing Then ckey.SetValue(" Type", CInt(272)) End If
Catch ex As Exception
OS_EventLog.Cre ateEventLogEntr y("After Install Failed: " & ex.ToString)
End Try
End Sub
This code works in the sense that the "Interacts with Desktop" checkbox IS checked, but I still don't see my icon show in the systray. If I manually go to my installed service and uncheck and then recheck and then start the service again -- my icon WILL show in the systray. Is there more than one reg entry to be set to make this work? Any hints or links where I can go to make this do the above two tasks work reliably?
Thanks, Rob.
Rob R. Ainscough wrote: If this is implemented due to security weakness in Vista, then I'd think
I don't know their reasons, but security was mentioned. Look for
"Windows Services Hardening". That might provide some additional
information.
What exactly is a "monitoring app"? I mean you've basically just defined what a service is, most services are monitoring/listeners sooo...
I just meant a GUI app that runs when the user logs on that then
communicates to the service. It would be this app that puts your icon
in the tray.
When the Windows Service starts, there is no system tray to place an
icon in, at least not until the user logs on. So your service will
have to somehow detect when a user logs on in order to place the icon
in that user's system tray. And what happens if someone at the machine
uses the "Switch User" feature, your service will have to be able to
detect that as well.
In any case, as I said earlier, you can use the
System.ServiceP rocess.ServiceC ontroller class to set that option. I
think it should work in your After_Install event as well.
Good luck
Greg/Chris,
Thanks for the responses -- I was able to make it work under any account
using the Committing event.
Like I said before, the UI part of my service doesn't really qualify as a
GUI -- my service just changes the icon image and the hover over message and
that is it -- it doesn't actually let the user do any, just informs the user
what it is currently doing -- one should not have to write two applications
to perform this task just because of an OS weakness. I guess I'm just
getting a little concern that MS just keep dumping on developers rather than
trying to actually make our life easier, they introduce worky solutions -- I
don't see how this is a good thing.
I realize there is some nasty spyware/adware/virus out there that can and
does take advantage of the systray, but this problem needs to be address in
a different way, lets not continue to reduce features so as to be "more
secure" -- that does no one any good and basically conceeds to the hackers
and those writing dubious software in the first place.
Rob.
"Chris Dunaway" <du******@gmail .com> wrote in message
news:11******** **************@ e56g2000cwe.goo glegroups.com.. . Rob R. Ainscough wrote: If this is implemented due to security weakness in Vista, then I'd think
I don't know their reasons, but security was mentioned. Look for "Windows Services Hardening". That might provide some additional information.
What exactly is a "monitoring app"? I mean you've basically just defined what a service is, most services are monitoring/listeners sooo...
I just meant a GUI app that runs when the user logs on that then communicates to the service. It would be this app that puts your icon in the tray.
When the Windows Service starts, there is no system tray to place an icon in, at least not until the user logs on. So your service will have to somehow detect when a user logs on in order to place the icon in that user's system tray. And what happens if someone at the machine uses the "Switch User" feature, your service will have to be able to detect that as well.
In any case, as I said earlier, you can use the System.ServiceP rocess.ServiceC ontroller class to set that option. I think it should work in your After_Install event as well.
Good luck
Hi Rob,
You know, I read your discussion and I've got this application which is dumb
in terms of UI, but just as you do, It would ideally need an icon in the tray
to display the application current condition (e.g. paused, running okay or
running with warnings). A context menu would also be nice, so that the user
could pause and resume. Is it possible for you to share your solution ?
Thanks, Jr.
"Rob R. Ainscough" wrote: Greg/Chris,
Thanks for the responses -- I was able to make it work under any account using the Committing event.
Like I said before, the UI part of my service doesn't really qualify as a GUI -- my service just changes the icon image and the hover over message and that is it -- it doesn't actually let the user do any, just informs the user what it is currently doing -- one should not have to write two applications to perform this task just because of an OS weakness. I guess I'm just getting a little concern that MS just keep dumping on developers rather than trying to actually make our life easier, they introduce worky solutions -- I don't see how this is a good thing.
I realize there is some nasty spyware/adware/virus out there that can and does take advantage of the systray, but this problem needs to be address in a different way, lets not continue to reduce features so as to be "more secure" -- that does no one any good and basically conceeds to the hackers and those writing dubious software in the first place.
Rob.
"Chris Dunaway" <du******@gmail .com> wrote in message news:11******** **************@ e56g2000cwe.goo glegroups.com.. . Rob R. Ainscough wrote: If this is implemented due to security weakness in Vista, then I'd think
I don't know their reasons, but security was mentioned. Look for "Windows Services Hardening". That might provide some additional information.
What exactly is a "monitoring app"? I mean you've basically just defined what a service is, most services are monitoring/listeners sooo...
I just meant a GUI app that runs when the user logs on that then communicates to the service. It would be this app that puts your icon in the tray.
When the Windows Service starts, there is no system tray to place an icon in, at least not until the user logs on. So your service will have to somehow detect when a user logs on in order to place the icon in that user's system tray. And what happens if someone at the machine uses the "Switch User" feature, your service will have to be able to detect that as well.
In any case, as I said earlier, you can use the System.ServiceP rocess.ServiceC ontroller class to set that option. I think it should work in your After_Install event as well.
Good luck This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Action |
last post by:
I can add a systray icon in normal windows application...
but when i do it in windows service, the systray icon just don't show up
is that because i don't have any "component" to contain the systray icon?
please give direction...
thx
|
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,
|
by: Jon Bosker |
last post by:
I have written an application that lives in the systray but when I try
to close windows or logout it does not close my application and
therefore prevents windows from shutting down or logging me out. It is
essential that I solve this problem but I have run out of ideas can
anyone help (please!)
The application starts in Start.cs which kicks off the Systray form
using this call:
Application.Run(new Systray());
|
by: Nate |
last post by:
We are attempting to make a request to a web service (we will refer to it as
XXXServices) hosted on a Web Logic server from a C# SOAP client. The server
responds with a 401 Unauthorized error (that appears in plain text), and
causes the client to crash. This C# code has been deployed both as an
ASP.NET application and a WinForms app, each of which produced the same
result. Further, moving the clients from a Windows XP machine to Windows...
|
by: Rotzooi |
last post by:
Hi,
I have a VB.NET Service application that's running fine under the Local
System account. But for configuration purposes I don't want to be dependent
on modifying the registry manually or using an seperate application (like I
do now).
I want to implement a system tray icon when someone logs on to the console.
I've tried several samples but I can't get the icon to the system tray. I
know there are some issues because the logged on...
| |
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
|
by: screwy |
last post by:
Hi! I've been trying to figure out how to enable desktop interaction
support for windows services from within my vb.net code desperatly, but
wasnt able to find anything useful. Does anyone know how to do this?
Thanks in advance for your help!
|
by: =?Utf-8?B?c3lzdGVtQ29uc3VsdGFudA==?= |
last post by:
Can I use EnumchildWindows from a windows service to find the IE windows and
Solitaire windows belonging to the logged on user?
And if so then I'll need to know what call to use to get the users desktop
window handle to enum them - Assuming GetDesktopWindow doesn't at this point.
I can do all this in a Forms application (trying to convert to service) but
as a service it simply doesn't think there are any of those windows open.
|
by: DM |
last post by:
Hi All,
I have written a server program which distributes real-time data to our
customers and is also used by our customers to redistribute this data over
their internal networks. The program is just a standard Windows application
which minimizes to the systray and runs in the background.
Recently I have been asked by one of our clients whether I can make this
program run as a Windows service. After some Googling, it looks like it is...
|
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...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
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...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |