Click here to Skip to main content
13,256,123 members (29,844 online)
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 2 Mar 2010

RWWinService - A Simplified .NET 3.5 branch of XYWinService

, 2 Mar 2010
Rate this:
Please Sign up or sign in to vote.
A branch/fork of Xiangyang Liu's XYNTService/XYWinService


This project is my personal branch of Xiangyang Liu's XYWinService.

In this version, I leverage my own SimpleService project to add features and solve a few minor annoyances.

New Features

  • Upgraded the solution to VS2008
  • Simplified configuration using app.config
  • Improved install/uninstall service support
  • Console mode - for simplified debugging
  • Logging to application event log
  • More command line options


I use RWWinService to run my fossil source repositories in the background. The following configuration is how I make that happen:

<?xml version="1.0" encoding="utf-8" ?>
    <section name="Process" 

      type="System.Configuration.IgnoreSectionHandler" />
    <add key="CheckProcessSeconds" value="30"/>
    <add key="PauseStartMs" value="1000"/>
    <add key="PauseEndMs" value="1000"/>
    <Arguments>server --port 8080 c:\rev\fossil\fossil.fossil</Arguments>
    <Arguments>server --port 8081 c:\rev\fossil\rwwinservice.fossil</Arguments>

There is a little bit of magic going on in this config file. Normally, the ConfigurationManager class expects to see only the appSettings element in the configuration, and it will throw an exception if unexpected elements are present. The configSections element lets you tell the ConfigurationManager class to ignore elements named Process and their children via the System.Configuration.IgnoreSectionHandler. Once that is done, you can parse the Process elements yourself in code. Alternatively, you could write your own SectionHandler, but I leave that to you. This gives us a simple, single configuration file.

The three appSettings keys are pretty much self-explanatory, and the Process elements are exactly the same as in XYWinService. I deprecated several configuration items that were available in XYWinService, most notably the RunAs element. This project assumes that the service will run as ServiceAccount.LocalSystem, and there is no configuration option that exposes this.

The Manifest

The manifest is the glue that makes it all come together. One line in particular configures the service to invoke the Vista/Windows7 UAC.

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Managing the Service

The RWWinService leverages the SimpleService framework, so the following command line options are available:

PS C:\rev\bin> RWWinService -help
= usage:
=   RWWinService -install   == install service
=   RWWinService -uninstall == uninstall service
=   RWWinService -start     == start service
=   RWWinService -stop      == stop service
=   RWWinService -status    == get the current status of the service
=   RWWinService -console   == run in console mode
=   RWWinService -help      == show this help message

Using these command-line switches, you can install and uninstall the service without using InstallUtil.exe. Also, you can start and stop the service once it is installed. The -status switch will tell you if the service is installed, started, or stopped.


I've been using this service for several months now without any problems. I think you will find the command-line interface saves you time. I am very much indebted to Xiangyang Liu for his original contribution; functionally, this branch of XYWinService provides the same basic feature set, only simplified and refactored. Please don't hesitate to notify me of bugs or oversights. Enjoy!


  • March 2010 - Initial submission


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ron wilson
Software Developer (Senior) Harris Corporation
United States United States
I'm your huckleberry.

Check out more beards here.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 2 Mar 2010
Article Copyright 2010 by ron wilson
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid