Jasinski Technical Wiki


Home Page
All Pages

Quick Search
Advanced Search »

Contributor Links

Create a new Page
File Management
Your Profile

Other Wiki Sections



Windows Services in Visual Studio 2005 Standard Edition

Modified on Fri, Sep 30, 2011, 7:53 PM by Administrator Categorized as ┬ĚNet Framework


To create a Windows Service in Visual Studio, typical instructions start with creating a Windows Service project. However, this project type is not available in Visual Studio 2005 Standard Edition. This articles is a walkthrough of creating a Windows Service in Visual Studio 2005 Standard Edition.


Creating the Project and Objects

  • Create a Console Application project.

  • Add a Windows Service item to the project.


  • In the Properties window, specify the (Name) and ServiceName properties. Then click the Add installer link.


  • Clicking the Add Installer link creates a Project Installer.cs file with two components: serviceProcessInstaller1 and serviceInstaller1.

  • For serviceProcessInstaller1, specify an Account property of LocalSystem.


  • For serviceInstaller1, specify a StartType of Automatic and specify a user-friendly name for DisplayName.


Coding the Service

  • In Program.cs, replace the Program class with the following code.

class Program
    static void Main()
        System.ServiceProcess.ServiceBase[] ServicesToRun
            = new System.ServiceProcess.ServiceBase[] { new WeatherWidgetService() };


  • In WeatherWidgetService.cs, replace the WeatherWidgetService class with the following code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.IO;

namespace Weather_Widget_Service
    partial class WeatherWidgetService : ServiceBase
        public WeatherWidgetService()
        protected override void OnStart(string[] args)
            // TODO: Add code here to start your service.
            WriteLog("Service started");
        protected override void OnStop()
            // TODO: Add code here to perform any tear-down necessary to stop 
            // your service.
            WriteLog("Service stopped");
        private void WriteLog(string msg)
            msg = "\n" + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + ">" + msg;
            File.AppendAllText(@"C:\Data\WeatherService.log", msg);

Deploying and Testing the Service

  • Build the service

  • Open a Visual Studio Command Window

  • Navigate to the folder containing the EXE (bin\Debug or bin\Release).

  • If the service is already installed from a previous installation, type the command installutil /u WeatherWidgetService.exe

  • Type the command installutil WeatherWidgetService.exe

  • Start the service via Control Panel > Administrative Tools > Services.

ScrewTurn Wiki version Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.