CJ

The circle of life – ** .Net – Training – MOSS **

  • Past Post

  • Vistor Locations

Installing a Windows Service using a Setup project

Posted by Clayton James on June 5, 2006

I recently created a .NET Windows Service that needed to be deployed on a range of servers in various environments (dev, uat, train, prod). I needed an easy way (automated) to achieve this as our operations staff were completing the deployment and the service need to run under an account that I didn't know about.

InstallUtil.exe

To manually deploy a .NET Windows Service you can use InstallUtil.exe. However, this is a command utility and would require the VS2005 command prompt tool and InstallUtil.exe to be installed, the user would need to manually type command switches to configure the service.

Update to post 

You can also use the command line tool "sc" to delete a service (as well as a whole bunch of other things, like set it to manual/auto, stop/start it, etc).

C:>sc delete
DESCRIPTION:
        Deletes a service entry from the registry.
        If the service is running, or another process has an
        open handle to the service, the service is simply marked
        for deletion.
USAGE:
        sc  delete [service name]

Setup Project

I won't go into detail as I found a great article that explains this. Simply put, the Setup project manages the installation of the Windows Service. It also manages a clean uninstall even when the service is running. This solution also allows me to use the User Interface Editor to add a Textboxes dialog so the person who is installing the service can input a Username and Password that the service account will run under. This uses the CustomActionEdit property to pass these values to the Windows Service installer which is another post in itself.

About these ads

20 Responses to “Installing a Windows Service using a Setup project”

  1. Mitko B said

    Thank you!
    Very pleasant article!

  2. Ram said

    I tried to install using a setup project, but it is not showing up in the service manager( where list of services are showed).Have you tried installing as mentioned in the article?

  3. Tincy said

    I am also facing the same trouble as Ram.
    Created service is not showing up in the service manager ,Can anyone help?
    Thanks

  4. CJ said

    You must install the service before it is displayed in Services.

    To install the service from the Setup project you need to right-click the Setup project and select install (Step 5: Use a complied Setup project to install the Windows Service).

    Once installed you will be able to view it at the following location:
    Click Start, point to Control Panel, point to Administrative Tools, and then click Services.

    Cheers

  5. pradeep said

    Hello CJ,

    nice idea but i am unable to locate any thing helpful , even “Link” you mentioned is not available,
    could u please put some helpsull stuff

    Actually i want to install two service using one installer.

    with Best Regards
    Pradeep

  6. Automobile said

    Hello…

    Looking for something else, but nice site. Have an excellent day….

  7. kcherupa said

    Please read this post which is an easy approach to install the windows services using setup project
    http://cherupally.blogspot.com/2009/09/how-to-create-setup-project-to-install.html

  8. Singh said

    How can we add Re-Install support to a windows service, so that if the service is installed again, we don’t have to first uninstall and then install the service?

  9. Just desire to mention your report is stunning.The clearness inside your submit is merely striking and i can get for granted you’re an specialist on this topic.Nicely with your authorization authorize me to grab your rss feed to keep up to date with future publish.Thanks a million and please continue the very good job. Excuse my inadequate English. English isn’t really my native language.

  10. Clifton said

    Thanks for the marvelous posting! I quite enjoyed reading it, you will be a great author.
    I will make sure to bookmark your blog and will come
    back in the foreseeable future. I want to
    encourage you to ultimately continue your great job, have
    a nice morning!

  11. Thanks in favor of sharing such a nice idea, piece of writing is nice,
    thats why i have read it completely

  12. We have encountered this discussion since we are in Orange County|an Orange County properties.

  13. I was very pleased to find this site. I need to to thank you for ones time for this particularly wonderful read!

    ! I definitely loved every little bit of it and i also have you
    saved as a favorite to check out new stuff on your site.
    I though you should know, I bookmarked Installing a Windows Service
    using a Setup project CJ at Digg so my friends will learn from it also.
    Could I also share a tip. Purchasing brilliant video marketing can also be fairly difficult.
    I find it most valuable to talk to a a Probate Attorney San Diego.

    Our crew of Amazing Estate Planning Attorney
    in San Diego are here to assist with all your legal needs.

  14. Everyone loves it when folks get together and share views.
    Great site, stick with it!

  15. Everything is very open with a very clear clarification of the
    issues. It was really informative. Your website is extremely helpful.

    Thanks for sharing!

  16. This is my first time go to see at here and i am in fact happy to read everthing at one place.

  17. Domingo said

    True, there are comedians that cuss a lot, but you got to earn that right before
    you do that. It is an industry norm that you offer a hotel room for the comedian at the same time.
    After you do all this, you are ready to start performing in front of people for money.

  18. Latesha said

    I am sure this piece of writing has touched all the internet viewers, its really really good paragraph on building up new website.

  19. Post writing is also a fun, if yyou know then you can write otherwise it is comnplex to write.

  20. personal injury attorney mn

    Installing a Windows Service using a Setup project « CJ

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 26 other followers

%d bloggers like this: