473,396 Members | 1,923 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,396 software developers and data experts.

How to install 2 times the same Service?

Hi,

I developped a Windows Service in VB.NET (2005).

I need to have it installed two times on 1 machine. When I want to install
it a second time, the setup doesn't allow me to install it again in an other
directory, but only to repair or remove the other version.

I get arround this by simply copying the files of the first installed in a
second directory.

But when I want to install the second service (so it would come in the
Services-list in the config panel) I can't do this, even if I rename it...

I should have somewhere the ability to change the name of a service at the
inside: somehow with a configfile that is read. I tried this using the
ServiceInstaller_BeforeInstall-event (in the ProjectInstaller), but it
doesn't seem to work...

Anybody any idea?

Thanks a lot in advance,

Pieter
Nov 21 '05 #1
4 1581
Try changing ProductCode.
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

I developped a Windows Service in VB.NET (2005).

I need to have it installed two times on 1 machine. When I want to install
it a second time, the setup doesn't allow me to install it again in an
other
directory, but only to repair or remove the other version.

I get arround this by simply copying the files of the first installed in a
second directory.

But when I want to install the second service (so it would come in the
Services-list in the config panel) I can't do this, even if I rename it...

I should have somewhere the ability to change the name of a service at the
inside: somehow with a configfile that is read. I tried this using the
ServiceInstaller_BeforeInstall-event (in the ProjectInstaller), but it
doesn't seem to work...

Anybody any idea?

Thanks a lot in advance,

Pieter


Nov 21 '05 #2
Pieter,
Short answer you can't.

Long answer: To install the service twice you would need to change:
1. The ServiceBase.ServiceName property of your service itself.
2. The ServiceInstaller.ServiceName property on the ServiceInstaller object
on your ProjectInstaller
3. Possibly any custom Performance Counters & Event Logs...

Do you always want to install 2 instances of the service or just
occasionally install 2 instances?

What I would normally do define 2 services in my assembly. The first
MyService1 inherits from System.ServiceProcess.ServiceBase and has all the
logic for both services. The Second MyService2 inherits from MyService1 and
changes the ServiceName property, plus overrides any custom Performance
Counters or Event Logs.

Then in my ProjectInstaller I would have 2 ServiceInstaller objects, one for
MyService1 & one for MyService2. Also in the Project Installer would be any
duplicate custom Performance Counters & Event Logs...

The "problem" is if both services are in a single EXE, then both are going
to be installed. If I wanted to optionally install one or both I would
define 2 EXEs and a DLL. The DLL would have MyServiceBase that inherits from
System.ServiceProcess.ServiceBase and has all the logic for both services.
The first EXE would have MyService1 inherits from MyServiceBase and changes
the ServiceName property, plus overrides any custom Performance Counters or
Event Logs. The second EXE would have MyService2 inherits from MyServiceBase
and changes the ServiceName property, plus overrides any custom Performance
Counters or Event Logs.

Alternatively you might (*might*) be able to use Dynamic Properties in the
designer to set both of the ServiceName properties, however I want to say
the ProjectInstaller is dynamically loaded under a different program, so it
won't find your app.config with the dynamic properties.

A third alternative might be to pass the service name as a CustomActionData
from the Setup project... This might be useful with the second
alternatively...

Hope this helps
Jay

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

I developped a Windows Service in VB.NET (2005).

I need to have it installed two times on 1 machine. When I want to install
it a second time, the setup doesn't allow me to install it again in an
other
directory, but only to repair or remove the other version.

I get arround this by simply copying the files of the first installed in a
second directory.

But when I want to install the second service (so it would come in the
Services-list in the config panel) I can't do this, even if I rename it...

I should have somewhere the ability to change the name of a service at the
inside: somehow with a configfile that is read. I tried this using the
ServiceInstaller_BeforeInstall-event (in the ProjectInstaller), but it
doesn't seem to work...

Anybody any idea?

Thanks a lot in advance,

Pieter

Nov 21 '05 #3
Hi,

Thanks a lot alreaddy for the answer.
Where do I find the ServiceBase.ServiceName-property? I can't find it
somewhere?

And should I change these in the ServiceInstaller1_BeforeInstall event?

The fact is: sometimes I have to isntall the Service only one time,
sometimes 2, sometimes 3 or four times :) It depends on the number of
COM-ports on the computer...

Pieter

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
Pieter,
Short answer you can't.

Long answer: To install the service twice you would need to change:
1. The ServiceBase.ServiceName property of your service itself.
2. The ServiceInstaller.ServiceName property on the ServiceInstaller object on your ProjectInstaller
3. Possibly any custom Performance Counters & Event Logs...

Do you always want to install 2 instances of the service or just
occasionally install 2 instances?

What I would normally do define 2 services in my assembly. The first
MyService1 inherits from System.ServiceProcess.ServiceBase and has all the
logic for both services. The Second MyService2 inherits from MyService1 and changes the ServiceName property, plus overrides any custom Performance
Counters or Event Logs.

Then in my ProjectInstaller I would have 2 ServiceInstaller objects, one for MyService1 & one for MyService2. Also in the Project Installer would be any duplicate custom Performance Counters & Event Logs...

The "problem" is if both services are in a single EXE, then both are going
to be installed. If I wanted to optionally install one or both I would
define 2 EXEs and a DLL. The DLL would have MyServiceBase that inherits from System.ServiceProcess.ServiceBase and has all the logic for both services.
The first EXE would have MyService1 inherits from MyServiceBase and changes the ServiceName property, plus overrides any custom Performance Counters or Event Logs. The second EXE would have MyService2 inherits from MyServiceBase and changes the ServiceName property, plus overrides any custom Performance Counters or Event Logs.

Alternatively you might (*might*) be able to use Dynamic Properties in the
designer to set both of the ServiceName properties, however I want to say
the ProjectInstaller is dynamically loaded under a different program, so it won't find your app.config with the dynamic properties.

A third alternative might be to pass the service name as a CustomActionData from the Setup project... This might be useful with the second
alternatively...

Hope this helps
Jay

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

I developped a Windows Service in VB.NET (2005).

I need to have it installed two times on 1 machine. When I want to install it a second time, the setup doesn't allow me to install it again in an
other
directory, but only to repair or remove the other version.

I get arround this by simply copying the files of the first installed in a second directory.

But when I want to install the second service (so it would come in the
Services-list in the config panel) I can't do this, even if I rename it...
I should have somewhere the ability to change the name of a service at the inside: somehow with a configfile that is read. I tried this using the
ServiceInstaller_BeforeInstall-event (in the ProjectInstaller), but it
doesn't seem to work...

Anybody any idea?

Thanks a lot in advance,

Pieter


Nov 21 '05 #4
Pieter,
Where do I find the ServiceBase.ServiceName-property? I can't find it
somewhere? Normally you set it in the properties when you have the designer of the
Service itself open.
And should I change these in the ServiceInstaller1_BeforeInstall event? ServiceBase.ServiceName cannot be changed in the ServiceInstaller per se, it
is a property of the service when the service runs.

The fact is: sometimes I have to isntall the Service only one time,
sometimes 2, sometimes 3 or four times :) It depends on the number of
COM-ports on the computer...
Rather then have a service for each COM-port I would probably create a
single service. Then that single service would have a single thread (or
group of threads) for each com port.

Hope this helps
Jay

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Hi,

Thanks a lot alreaddy for the answer.
Where do I find the ServiceBase.ServiceName-property? I can't find it
somewhere?

And should I change these in the ServiceInstaller1_BeforeInstall event?

The fact is: sometimes I have to isntall the Service only one time,
sometimes 2, sometimes 3 or four times :) It depends on the number of
COM-ports on the computer...

Pieter

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
Pieter,
Short answer you can't.

Long answer: To install the service twice you would need to change:
1. The ServiceBase.ServiceName property of your service itself.
2. The ServiceInstaller.ServiceName property on the ServiceInstaller

object
on your ProjectInstaller
3. Possibly any custom Performance Counters & Event Logs...

Do you always want to install 2 instances of the service or just
occasionally install 2 instances?

What I would normally do define 2 services in my assembly. The first
MyService1 inherits from System.ServiceProcess.ServiceBase and has all
the
logic for both services. The Second MyService2 inherits from MyService1

and
changes the ServiceName property, plus overrides any custom Performance
Counters or Event Logs.

Then in my ProjectInstaller I would have 2 ServiceInstaller objects, one

for
MyService1 & one for MyService2. Also in the Project Installer would be

any
duplicate custom Performance Counters & Event Logs...

The "problem" is if both services are in a single EXE, then both are
going
to be installed. If I wanted to optionally install one or both I would
define 2 EXEs and a DLL. The DLL would have MyServiceBase that inherits

from
System.ServiceProcess.ServiceBase and has all the logic for both
services.
The first EXE would have MyService1 inherits from MyServiceBase and

changes
the ServiceName property, plus overrides any custom Performance Counters

or
Event Logs. The second EXE would have MyService2 inherits from

MyServiceBase
and changes the ServiceName property, plus overrides any custom

Performance
Counters or Event Logs.

Alternatively you might (*might*) be able to use Dynamic Properties in
the
designer to set both of the ServiceName properties, however I want to say
the ProjectInstaller is dynamically loaded under a different program, so

it
won't find your app.config with the dynamic properties.

A third alternative might be to pass the service name as a

CustomActionData
from the Setup project... This might be useful with the second
alternatively...

Hope this helps
Jay

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I developped a Windows Service in VB.NET (2005).
>
> I need to have it installed two times on 1 machine. When I want to install > it a second time, the setup doesn't allow me to install it again in an
> other
> directory, but only to repair or remove the other version.
>
> I get arround this by simply copying the files of the first installed
> in a > second directory.
>
> But when I want to install the second service (so it would come in the
> Services-list in the config panel) I can't do this, even if I rename it... >
> I should have somewhere the ability to change the name of a service at the > inside: somehow with a configfile that is read. I tried this using the
> ServiceInstaller_BeforeInstall-event (in the ProjectInstaller), but it
> doesn't seem to work...
>
> Anybody any idea?
>
> Thanks a lot in advance,
>
> Pieter
>
>



Nov 21 '05 #5

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

Similar topics

0
by: MarkM | last post by:
Hi there. Since upgrading to XP SP2 on my development box, I now compile the same windows service code and try to install it on a Windows 2000 server. Throws error "Access Is Denied". The...
4
by: DraguVaso | last post by:
Hi, I developped a Windows Service in VB.NET (2005). I need to have it installed two times on 1 machine. When I want to install it a second time, the setup doesn't allow me to install it again...
3
by: Jeremy S. | last post by:
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 . 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:...
2
by: | last post by:
i run the following: installutil "my service.exe" and it goes through and tells me the install and commit were successful. i go to the services list and it isn't shown. i've done this...
2
by: John | last post by:
Hi I have a vb.net service app which I have set to run as user. When I try to install the service via InstallUtil, I provide user/pass for the administrator but the service fails to install. I...
6
by: Jean-Marc Blaise | last post by:
Hi, How can I make MSSQL2K5 setup install everything in the install path I have choosen - it keeps installing some files in ¨%SystemRoot% ? Thanks, JM
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
12
by: Matt Fielder | last post by:
I tried to install SP1, and it appears to have just stopped somewhere part way through. It was "collecting information" (for a long time, slow progress bar) --- then suddenly it stopped.... no...
1
by: kataoki | last post by:
Hi, This is the log file for my SP1 on 2005 install. Can anyone please look at this and tell me if this looks normal? I'm concerned about the following in the log: "Failed to read registry...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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,...

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.