Link to home
Start Free TrialLog in
Avatar of D B
D BFlag for United States of America

asked on

Create a Windows Service for Dummies

I want to buld a Windows Service. It will run on a machine, and will contain a FileSystemWatcher to monitor a directory. When a new file arrives, I want to send an email with that file as an attachment, then move the file to a different directory (upon success). I am basically an application developer, and although I am fairly proficient with prior versions of VB, am still getting my feet wet with .NET.

I've added a new project, and made it a Windows service. I've added a reference to Outlook and I've added a FileSystemWatcher to the design page and set its properties. One thing I want to do, and don't have an idea how to is to add an icon in the taskbar notification area when the service starts. Right-clicking on the icon would open a popup menu with an option to stop the service and also have an indication that Outlook is running (perhaps 'Outlook' as an item with a checkmark next to it if it is running). I would like to possibly change the appearance of the icon if an error occurred while the service is running (unable to send file, error occurred moving the file after sending the message, etc.).
ASKER CERTIFIED SOLUTION
Avatar of vb_jonas
vb_jonas
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of D B

ASKER

Well, I am definately delving into new territory here and obviously there is no simple cut-and-paste solution, but I am hoping this can help me get started.

This particular project was pushed to a lower priority after I asked the question, so it may be awhile before I get back to it, but I am going to PAQ it for now and work my way through it when I get a chance. Thanks for hopefully getting me pointed in the right direction.
Avatar of D B

ASKER

If you don't mind me asking one quick question. I'm still not deep into theis, but doing a little research. Unless I am mistaken, I actually need two projects; one is the service itself, the second is a Windows application (which the link above references) that actually allows me to control the service. Is that correct?

If I am reading stuff properly, I would install the service (in my case have StartType = Automatic), and then in my Startup execute the 'controller' program?
Hi!
If you would stop/stop the service you would need to create another app to do it, I would prefer doing it that way. But it would also be possible to have the service running all the time, and let itself controll when to start/stop the FileSystemWatcher.