Wednesday, March 4, 2009

How can i install/remove a .net windows service using InstallUtil?

With Community Server 2007.1, it is now possible to install multiple instances of a Windows
Service without the need for custom MSI builds. This is done by manually
installing the Windows Service with the command line utility and specifying the
name of the service to be used.

Previously, the limitations on multiple installs were due to the product name installed with
the MSI, the hard coded service name in the service installer, and also some
registry keys that were needed by the installer. Doing multiple
installations required these to be manually changed in code and re-compiled in
a custom build.

With the new version, the hard coded limitations have been removed, allowing for one
instance of the add-ons to be installed with the MSI, and then additional
instances of the program to be activated through the command line.


How to Install

In order to install additional instances of the service, you will need to use the
InstallUtil.exe program that is included with the .NET Framework SDK (available
here
). The InstallUtil.exe program is located in the .NET Framework's
installation directory, which will typically be in the
following directory:

C:\Windows\Microsoft.NET\Framework\v2.0.50727

First, you will need to create the first instance by installing using the MSI package. This extracts all of the files and allows you to quickly install your first instance. To create a second instance, you will need to make a copy of the installation directory, since the second instance will need its own set of files, configuration, and will run separately from the first instance.
The add-ons are normally installed to a folder in C:\Program Files\Telligent by default.

Once you have created a copy of the add-on's installation files, you need to register it with
Windows as a service. To activate it, you will install the service using InstallUtil.exe and add a /name parameter to specify what the service will be named. The names have to be unique, so if you already have " PostGreSQL Backup Service ", you might need to name it "PostGreSQL Backup Service". You then specify the filename of the Windows Service, which is usually like “
postgrebackup.exe ". So for example, it would be:

installutil c:\postgrebackup\postgrebackup.exe /LogToConsole=true /LogFile=c:\backuplog.log

You would need to run this from a command prompt within the add-ons directory. The name
must be in quotes if it contains spaces, and it must come before the filename. After installation, if you bring up the Windows Services console (Start, Run, services.msc), you should find the new service installed and listed alphabetically.

You may need to add the path to the InstallUtil.exe program onto the command if the .NET
Framework folder isn't in your PATH setting.

How to Uninstall

Uninstalling the service is very similiar to installing. You will still use the InstallUtil.exe program and will need to specify the name of the service to uninstall, though this time you will need to add a /u switch to specify that you intend to uninstall it. For instance:

InstallUtil /u /name=" PostGreSQL Backup Service" postgrebackup.exe

The name must be specified since if you have multiple instances of the same executable
installed, it will need to know which one. If no name is specified, it will remove the one with the default name as opposed to a custom named one.

Again, the uninstall and name parameters must come before the filename so that it know they are for that file.

You may need to add the path to the InstallUtil.exe program onto the command if the .NET
Framework folder isn't in your PATH setting.




No comments: