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 ProjectInstaller.vb
Private Sub ServiceInstaller1_AfterInstall(ByVal sender As
System.Object, ByVal e As System.Configuration.Install.InstallEventArgs)
Handles ServiceInstaller1.AfterInstall
Dim OS_EventLog As New MyStuff.Utilities.OperatingSystem
Try
Dim KeyPath As String = "SYSTEM\CurrentControlSet\Services\" &
Me.ServiceInstaller1.ServiceName
Dim ckey As RegistryKey =
Registry.LocalMachine.OpenSubKey(KeyPath, True)
If ckey IsNot Nothing Then
ckey.SetValue("Type", CInt(272))
End If
Catch ex As Exception
OS_EventLog.CreateEventLogEntry("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 2626
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*****@pacbell.net> wrote in message
news:uh**************@TK2MSFTNGP05.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 ProjectInstaller.vb
Private Sub ServiceInstaller1_AfterInstall(ByVal sender As System.Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles ServiceInstaller1.AfterInstall
Dim OS_EventLog As New MyStuff.Utilities.OperatingSystem
Try
Dim KeyPath As String = "SYSTEM\CurrentControlSet\Services\" & Me.ServiceInstaller1.ServiceName Dim ckey As RegistryKey = Registry.LocalMachine.OpenSubKey(KeyPath, True)
If ckey IsNot Nothing Then ckey.SetValue("Type", CInt(272)) End If
Catch ex As Exception
OS_EventLog.CreateEventLogEntry("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.ServiceProcess.ServiceController to set the ServiceType property
using the InteractiveService 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.googlegr oups.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.ServiceProcess.ServiceController to set the ServiceType property using the InteractiveService 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*****@pacbell.net> wrote in message
news:e$**************@TK2MSFTNGP02.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.googlegr oups.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.ServiceProcess.ServiceController to set the ServiceType property using the InteractiveService 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***************@TK2MSFTNGP04.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*****@pacbell.net> wrote in message news:uh**************@TK2MSFTNGP05.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 ProjectInstaller.vb
Private Sub ServiceInstaller1_AfterInstall(ByVal sender As System.Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles ServiceInstaller1.AfterInstall
Dim OS_EventLog As New MyStuff.Utilities.OperatingSystem
Try
Dim KeyPath As String = "SYSTEM\CurrentControlSet\Services\" & Me.ServiceInstaller1.ServiceName Dim ckey As RegistryKey = Registry.LocalMachine.OpenSubKey(KeyPath, True)
If ckey IsNot Nothing Then ckey.SetValue("Type", CInt(272)) End If
Catch ex As Exception
OS_EventLog.CreateEventLogEntry("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.ServiceProcess.ServiceController 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.googlegr oups.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.ServiceProcess.ServiceController 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.googlegr oups.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.ServiceProcess.ServiceController 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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: 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: 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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |