473,738 Members | 7,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.e xe].

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 56997
> 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.e xe].

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.c om> wrote in message
news:37******** *************@n ews.microsoft.c om...
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.e xe].

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 "ServiceSolutio n".

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 "TestServic e". 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
"TestServic e", including the string used to name the service in th
InitializeCompo nent() method.

In the design view, right click and select "Add Installer" from th
context menu. A new source file "ProjectInstall er.cs" with the clas
named "ProjectInstall er" will be added to the project. Two component
will also be added to your project with the default name
"serviceInstall er1" and "serviceProcess Installer1". 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 "serviceProcess Installer1
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 "serviceInstall er1" component in the design view. I
the properties window, the name property should be set to "TestServic e
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 "ServicesDepend edOn" 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 "DisplayNam e" 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 "ProjectInstall er" 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(IDictio nary mySavedState)
{
// call the original Install() method to create root key
base.Install(my SavedState);

Microsoft.Win32 .RegistryKey ServiceDescript ion = null;
try
{
ServiceDescript ion
=.Win32.Registr y.LocalMachine. OpenSubKey(@"Sy stem\CurrentCon trolSet\
Services\" + ServiceInstalle r1.ServiceName, true);
ServiceDescript ion.SetValue("D escription", "This is our test service
description.");
ServiceDescript ion.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 "Descriptio n" 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 "ServiceSolutio n" and choose
"Add." then "New Project." from the context menu. From the "Setup and
Deployment Projects" folder, select "Setup Project" and then name it
TestServiceInst all".

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 "TestServiceIns tall" 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 "Applicatio n Folder" in the project pane and select "Add."
and "Project Output." from the context menus.

Make sure that the "TestServic e" project is selected in the project
drop-down and then click on "Primary Output" in the list box. Keep the
"Configurat ion" 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
"ProcessInstall er" 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 "Applicatio n 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 "TestServiceIns tall"
project and choose "Build" from the context menu.

When the "TestServiceIns tall.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
3290
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. then i used the windowsservice.exe in setup deployment project.
0
2764
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 am unable to install again: Running a transacted installation. Beginning the Install phase of the installation.
2
7985
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: System.IO.FileNotFoundException: File or assembly name windowsservice1, or one of its dependencies, was not found.. " I am new to C# environment. Any idea any clue will be appreciated. Thanks using System;
3
4043
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 Install(IDictionary savedState) { Application.Run(new MyForm()); base.Install(savedState);
4
3180
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
3077
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 have added a projectinstaller also for that. I have used following settings for it (developed in VS 2005 only): 1. For Service1.cs file, I have kept the default values. i.e. Name of
5
7712
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 installing .NET framework 3.0 I got the error: "Microsoft .NET Framework 3.0 x86 has encountered a problem during setup. Setup did not complete correctly." Error Signature:
2
13324
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, but it must install a web service in IIS too.
0
2128
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 application, but it also includes a Windows Service. My custom install actions configuration includes output from a Class Library project that contains the custom actions followed by the output of the Windows Service project to register the service....
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9208
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.