473,394 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How in Install Windows Service

On my dev machine (XP/Pro with VS.NET 2003) I have been developing a Windows
Service and installing it on the local machine by opening the Visual Studio
Command Prompt and then executing [InstallUtil.exe MyServiceName.exe].

Now I want to test this service on a Windows Server 2003 box that doesn't
have the Visual Studio Command prompt.

How do I go about installing the service on the Windows Server 2003 box?

Thanks!
Nov 16 '05 #1
3 56890
> On my dev machine (XP/Pro with VS.NET 2003) I have been developing a
Windows Service and installing it on the local machine by opening the
Visual Studio Command Prompt and then executing [InstallUtil.exe
MyServiceName.exe].

Now I want to test this service on a Windows Server 2003 box that
doesn't have the Visual Studio Command prompt.

How do I go about installing the service on the Windows Server 2003
box?


IIRC, same way. InstallUtil is located in the framework directory in the
windows directory.

Nov 16 '05 #2
You are correct... (whew). I googled this topic before posting the question
and all the hits I looked at were from people who were claiming that
InstallUtil.exe was not to be distributed and they were therefore creating
installer packages. It looked like a lot of work and I just couldn't believe
it - thus my post.

Thanks again.
"Ryan Trudelle-Schwarz" <ne**@mamanze.com> wrote in message
news:37*********************@news.microsoft.com...
On my dev machine (XP/Pro with VS.NET 2003) I have been developing a
Windows Service and installing it on the local machine by opening the
Visual Studio Command Prompt and then executing [InstallUtil.exe
MyServiceName.exe].

Now I want to test this service on a Windows Server 2003 box that
doesn't have the Visual Studio Command prompt.

How do I go about installing the service on the Windows Server 2003
box?


IIRC, same way. InstallUtil is located in the framework directory in the
windows directory.

Nov 16 '05 #3

Hey Jeremy,

I've been using a document i found online yonks ago as a directive a
to how to build and install the service and it works just fine..

i've copied and pasted the contents of the document below..

__________________________________________________ __________

Overview

In order to simplify deployment for service applications that i
developed with Microsoft .NET and Visual Studio 2002/2003, component
are provided that can be used to set up the registry keys and perfor
the installation time registration of the .NET service.

These instructions assume a simple project that consists of one servic
application and the actual installation project that will be used t
install the service.

Creating the solution

To create the solution, use "File." "New." and select "Blank Solution.
from the Visual Studio development environment. For this example, cal
the solution "ServiceSolution".

All related projects (especially those that will be part of a
installation, should become a project within the root solution. Thi
keeps all inter-project dependencies relative to one another an
simplifies the process if another developer decides to use a workin
folder.

The next step is to create two new projects as part of this solution
the service application and the installation package. Right click o
the solution within the Solution Explorer and select "Add." and the
"New Project." from the Visual C# projects folder, choose "Window
Service". Name the project "TestService". The resulting project shoul
now be in design mode and ready to add the installation components.

The C# source file "Service1" and the class name "Service1" are adde
to the project; replace all occurrences of "Service1" wit
"TestService", including the string used to name the service in th
InitializeComponent() method.

In the design view, right click and select "Add Installer" from th
context menu. A new source file "ProjectInstaller.cs" with the clas
named "ProjectInstaller" will be added to the project. Two component
will also be added to your project with the default name
"serviceInstaller1" and "serviceProcessInstaller1". These component
use the .NET framework to handle the registry key setup an
installation of the service. You can opt to change the names of thes
components, but for this example keep them the same.
Service properties

In the design view, you can select the "serviceProcessInstaller1
component and modify its properties. For the "account" property, yo
can choose the type of account this service will use. For a use
account, a name and password can be supplied in the code, but thi
should not be done. For production services, the service type shoul
typically be user and then the name and password set to 'null'. A
installation time, the production support personnel will be prompted t
enter the name and password for the account under which the servic
will run. Be sure to specify what resources will be required by th
application so that the account's permissions may be se
appropriately.

Next, select the "serviceInstaller1" component in the design view. I
the properties window, the name property should be set to "TestService
which is the name of the class we chose for our service. You only nee
to change this property if you want the Service Control Manager t
recognize your service with a different name.

In the "ServicesDependedOn" property, add the service name (as shown i
the Service Control Manager) of any other dependent services that you
service requires. This can be other services such as Microsoft Messag
Queuing, IIS, etc.

For the "DisplayName" property, choose a short friendly name that i
displayed when the services are listed in the control panel. For ou
service, we'll use "Test Service" (with a space).
Adding a description

You'll note that there is no description property available for th
service through any of the components. In order to add a usefu
description to the service that can be read by anyone, some code wil
need to be added to the "ProjectInstaller" class that was created.

We'll want to add a registry key under the same location where the
other service properties are kept. To do this, we will override the
virtual
Install() method, call the base class Install() in order to create the
root registry keys, then add our new key with the description.


public override void Install(IDictionary mySavedState)
{
// call the original Install() method to create root key
base.Install(mySavedState);

Microsoft.Win32.RegistryKey ServiceDescription = null;
try
{
ServiceDescription
=.Win32.Registry.LocalMachine.OpenSubKey(@"System\ CurrentControlSet\
Services\" + ServiceInstaller1.ServiceName, true);
ServiceDescription.SetValue("Description", "This is our test service
description.");
ServiceDescription.Close();
}
catch(Exception)
{}
}
Note that we don't need to worry about any other overrides to remove
the key. When the root key is removed by the service installer base
class, the new "Description" key will be removed as well since it is a
child of that key.

Note also that the name property was used to create the service name.
This is to avoid hard-coding the name should it ever change and ensures
we create the correct key name based on the service name.

The service is now ready to be developed in accordance to the service
specification; prior to development, however, we can create the
installation package along with the custom steps required to install
the product.
MSI Package setup

The final step of the exercise is to create the MSI installation
package that will be used to install our test service. From the
Solution Explorer, right click on the "ServiceSolution" and choose
"Add." then "New Project." from the context menu. From the "Setup and
Deployment Projects" folder, select "Setup Project" and then name it
TestServiceInstall".

Instead of focusing on the various properties for the installation,
instead we will just go through the steps required to install the
service
application and then execute the service installation components that
will occur when the MSI is deployed.

With the "TestServiceInstall" project selected in the Solution
Explorer, you should see icons appear over the project folders. Select
the first icon which is the "File System" installation folders. Right
click on the "Application Folder" in the project pane and select "Add."
and "Project Output." from the context menus.

Make sure that the "TestService" project is selected in the project
drop-down and then click on "Primary Output" in the list box. Keep the
"Configuration" dropdown to "(Active)". This will allow the
installation project to use the appropriate output for either a debug
or release build depending upon which you choose to create for the
installation. (Debug builds are useful for development/stage
environment deployment in some testing situations.)

The fifth icon on the top is the "Custom Actions" editor. Custom
actions can be callbacks in code (in this case, they are part of the
"ProcessInstaller" class that was created for us). We need to
associate the "primary" output of our application to each of the custom
installation steps.

To do this in one fell swoop, click the "Custom Actions" icon to show
the actions view. There are several folders with the names "Install",
"Commit", "Rollback" and "Uninstall". Right click on the top level
"Custom Actions" node and select "Custom Action."

In the next dialog, open the dropdown and select "Application Folder".
You should now see the "Primary output from TestService (Active)" in the
list view, as this is where we added our project's output. Select this
item in the list and choose "OK". The primary output for the service
will now be associated with all of the custom actions and the service
installer classes that were added to the project will now be called to
perform the various installation steps when the MSI package is
deployed.

Testing

We are now ready to create the installation package and see the results
of the service installation. Right click on the "TestServiceInstall"
project and choose "Build" from the context menu.

When the "TestServiceInstall.msi" file is created, navigate to the
output folder where it was placed and double click on it to perform the
installation. The other installation properties (such as the splash
screen display name, copyright information, other dependencies, etc.)
can be added as needed as this is only a test project.

When installing, choose "Everyone" for the installation and continue to
click next. You will eventually be prompted with the dialog to enter
your login name and credentials. You can use your network logon for
testing purposes. When installation is complete, use the
Administrative Tools to view the installed service applications. You
should see the "Test Service" along with its description and the
credentials used by the service application.

After closing the services window, use the "Add/Remove Programs"
functionality from the Control Panel to uninstall the service and it
should no longer appear in list of available services.
--
Deprecated
------------------------------------------------------------------------
Deprecated's Profile: http://www.msusenet.com/member.php?userid=20
View this thread: http://www.msusenet.com/t-940460

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: raghavendra | last post by:
Hi, How to run automatically windows service by using setup deployment insatllation script using visual studio 2003.? What i did is :-- 1. created a windows service & tested the same. 2....
0
by: Stuart Whelan | last post by:
I am writing a service in C# with an internal service installer. I am running XP Pro SP with VS7.1 and .NET 1.1 It installed okay the first time, but during uninstall the app crashed. Now I...
2
by: Fan Wang | last post by:
Hi All, I wrote a windows service with C# as below. But I can't install it with installutil.exe. I got an error message " Exception occurred while initializing the installation:...
3
by: Chad Smith | last post by:
Hi, I have created a .NET deployment project in Visual Studio 2003. I have specified an entry point into my own code in this installer which launches into the familiar: public override void...
4
by: kkt49 | last post by:
# vim: et sw=4 ts=8 sts from wxPython.wx import * import sys, os, time import pywintypes import win32serviceutil import win32service import win32event import win32process
3
by: JM | last post by:
Hi, I have created a Solution in VS 2005 with 2 simple projects. First project is simple Windows Service which writes an entry into event log when it starts and when it stops. Nothing else. I...
5
by: Ajith Menon | last post by:
I have to install .NET framework 3.0. I already have .NET Framework 1.1 installed on my machine. I don't want to remove framework 1.1 since some of the critical applications are using it. While...
2
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
I know this has been answered, I just can't find it. can someone point me to a URL or thread that shows how to install a web service in a Windows Setup Project ? I need to install a windows app,...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Actually, my installer package is not for a Windows Service, but for a WinForms application. Well, it is kind of both: this is a multi-project solution with its main target being a WinForms...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.