Create windows service setup in visual studio

Windows service can be setup by using DOS command but that is not so easy especially for those people who are not technically strong, some time we create windows service for our client and the want a setup file so they simply click on the setup file and follow the instruction. So we will see how to create a windows service setup with Visual Studio. To learn how to create windows service see my previous post how to create windows service in C# visual studio 2010

Let’s start creating a windows service setup

  1. From File menu select New => Project…
  2. From Installed Templates select Other Project Types => Setup and Deployment
  3. Select Setup Project
    • If no template is coming then on the right side there is “Search Installed Templates”
    • Type there Setup and
    • Select “Setup Project”
  4. Give name to your project say “My Windows Service”
  5. File System template will be opened
  6. From File System on Target Machine select “Application Folder”
  7. Right click in right pan and select Add => File
  8. Navigate to your Windows Service bin folder
  9. Select all the files from bin folder and click open
  10. Now your all the files are added to the application

Some property setting which need to be adjust according to our requirements so click on project name and press F4 to open the property window

  • Auther: Company Name
  • InstallAllUsers: True/False
  • Manufacturer: Company Name
  • ProductName: My Windows Service
  • Title: My Windows Service

alt text Till now whatever we setup, will not register our service to “Services” of the system so what more we need to do so once we install it, it register with system services, we need to add custom action

  1. Expand Solution Explorer
  2. Select project name
  3. There are some icons in solution explorer (see in image)
  4. Click on Custom Actions Editor it will open Custom Action tab
  5. Right click on Custom Action => Add Custom Action
  6. It will open a window to select exe
  7. Click on Application Folder
  8. Select your windows service EXE file
  9. Click OK

Now we are don to setup, rebuild you application

Go to your application folder and see debug folder, it contain two files

  1. My Windows Service
  2. setup

These two are files which you need to setup your windows service any where.

Ali Adravi Having 13+ years of experience in Microsoft Technologies (C#, ASP.Net, MVC and SQL Server). Worked with Metaoption LLC, for more than 9 years and still with the same company. Always ready to learn new technologies and tricks.
  • windows service
  • c#
  • setup
By Ali Adravi On 11 May, 13  Viewed: 1,276

Other blogs you may like

How to create windows service in C# visual studio 2010

Creating windows service in C# is really easy but when we need to create first time we face many problems so in this post we will try to learn everything about window service. In this article we will create a windows service which will run after a particular interval, and time should be... By Ali Adravi   On 30 Apr 2013  Viewed: 8,427

default value for different data type in C#

In C# there are different data type and they use some default value when we declare a variable. When we define a variable of type int or Int32 say int score; so what is the value of score, will it be null or zero, in the same way if we create a variable of type string/String what value it holds... By Ali Adravi   On 27 Mar 2013  Viewed: 2,498

enum in C# and conversion

An enumeration type (also known an enumeration or an enum) provides an efficient way to define a set of named integral constants that may be assigned to a variable to make programming clear, understandable and manageable. There are ways of using, like how to use enum in switch and case statement,... By Hamden   On 27 Mar 2013  Viewed: 4,291

Dynamic vs var in C# with example

When we have var which dynamically holds any type or value so why we need dynamic type, what are the differences and situations where we can use dynamic rather than var, there were some question in my mind so I explored more which I want to share here. There are two things, static type and... By Nathan Armour   On 26 Mar 2013  Viewed: 3,072

Array in C# - single, multiple and jagged array

An array can be initialized in several ways, it can store a single value or series of values, every element must be set of same type, C# supports single-dimensional arrays, multidimensional arrays (also call rectangular array) and array-of-arrays (referred jagged arrays), let’s discuss features of... By Ali Adravi   On 24 Mar 2013  Viewed: 3,988