|
tech
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Install Windows Service with command line argsI'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. 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/WindowsServiceInstall.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 (waw***@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. 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: Show quote > 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/WindowsServiceInstall.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 (waw***@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. > > 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 (waw***@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. |
|||||||||||||||||||||||