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

Install Windows Service with command line args

P: n/a
I'm trying to install a .NET Windows Service using the ServiceInstaller /
ServiceProcessInstaller classes. I cannot seem to find a way to specify
command line arguments.

I've looked through ServiceInstaller:Install method using reflector and it
appears that it is not possible.

According to the Win32 doco, the CreateService function in advapi32.dll
should be able to accept arguments to the binaryPath parameter. However the
Install method does not allow for this.
Nov 21 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Robert,

It's a known limitation that currently .NET ServiceProcessInstaller doesn't
expose a way to specify a command line to the process. We have to
workaround this by using the SCM (Service Control Manager) directly. Here's
an example in VB.NET:

#Install a Windows service the way YOU want to! - The Code Project - VB.NET
http://www.codeproject.com/vb/net/Wi...iceInstall.asp
By the way, we can now specify the description in .NET 2.0 (not available
in 1.1) using ServiceProcessInstaller. Here's another article on this:

#BCL Team Blog : Installing a Managed Service with a Custom Name [Robert
Villahermosa]
http://blogs.msdn.com/bclteam/pages/577672.aspx
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 22 '07 #2

P: n/a
Thanks Walter,

Just confirming what I suspected. Just had a look at the .NET 3.5 assembly
list and there has been no change. Opportunity missed ?

Anyway, we solved this issue inheriting from the ServiceInstaller class then
opening the RegKey directly and amending the ImagePath value to include the
commandline parameters required

Hack... maybe but it worked!!

""Walter Wang [MSFT]"" wrote:
Hi Robert,

It's a known limitation that currently .NET ServiceProcessInstaller doesn't
expose a way to specify a command line to the process. We have to
workaround this by using the SCM (Service Control Manager) directly. Here's
an example in VB.NET:

#Install a Windows service the way YOU want to! - The Code Project - VB.NET
http://www.codeproject.com/vb/net/Wi...iceInstall.asp
By the way, we can now specify the description in .NET 2.0 (not available
in 1.1) using ServiceProcessInstaller. Here's another article on this:

#BCL Team Blog : Installing a Managed Service with a Custom Name [Robert
Villahermosa]
http://blogs.msdn.com/bclteam/pages/577672.aspx
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 22 '07 #3

P: n/a
Hi Robert,

Thanks for your quick reply.

We have recorded this post in our database, hopefully it will be added in
future versions.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.