By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,034 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,034 IT Pros & Developers. It's quick & easy.

How to install Windows Service

P: n/a
Could someone suggest me as to how to install an
Windows Service in C#? I do not want to use InstallUtil
as I need to pass a parameter, which is not possible.
I do not want to use write an installer application
either. I want to install from Command Line prompt
from .NET and pass in different parameter values
hsomething
like,
ServiceName /Install
/ABC=""
/XYZ=""

Thank you in advance
-Shani

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Shani" <an*******@discussions.microsoft.com> wrote in message
news:36****************************@phx.gbl...
Could someone suggest me as to how to install an
Windows Service in C#? I do not want to use InstallUtil
as I need to pass a parameter, which is not possible.
I do not want to use write an installer application
either. I want to install from Command Line prompt
from .NET and pass in different parameter values
hsomething
like,
ServiceName /Install
/ABC=""
/XYZ=""


Use the ServiceInstaller class but, don't add the [RunInstaller] attribute.
Then, in your service's "main", look for the /Install parameter, if it's
present, create an instance of your ServiceInstaller based class and call
the .Install method.
Nov 16 '05 #2

P: n/a
"John Vottero" <Jo**@mvpsi.com> wrote in message
news:u4**************@TK2MSFTNGP11.phx.gbl...
"Shani" <an*******@discussions.microsoft.com> wrote in message
news:36****************************@phx.gbl...
Could someone suggest me as to how to install an
Windows Service in C#? I do not want to use InstallUtil
as I need to pass a parameter, which is not possible.
I do not want to use write an installer application
either. I want to install from Command Line prompt
from .NET and pass in different parameter values
hsomething
like,
ServiceName /Install
/ABC=""
/XYZ=""


Use the ServiceInstaller class but, don't add the [RunInstaller]
attribute. Then, in your service's "main", look for the /Install
parameter, if it's present, create an instance of your ServiceInstaller
based class and call the .Install method.


Actually, your class should be based upon Installer and it will contain a
ServiceInstaller and a ServiceProcessInstaller, just like the examples in
the doc. The key difference is that you will be creating an instance and
calling .Install instead of leaving that up to InstallUtil or some other
installer.
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.