Home All Groups Group Topic Archive Search About

How to access "start parameters" on a Windows Service?

Author
15 Jan 2007 11:26 PM
Jen
I have a Windows Service written in C# 2.0.  I need to pass a parameter
using the Startup parameters feature of the service properties.  I figured
it would pass it to the executable as a command-line parameter but it
doesn't seem to work like that.  How does my C# code access the service
start parameters?

Author
15 Jan 2007 11:35 PM
Ashot Geodakov
If you derive your service from System.ServiceProcess.ServiceBase, then one
of the methods you override is

protected override void OnStart( string[] args )

The string[] args are your startup parameters.

Show quote
"Jen" <n***@nowhere.com> wrote in message
news:OOYLPyPOHHA.3944@TK2MSFTNGP06.phx.gbl...
>I have a Windows Service written in C# 2.0.  I need to pass a parameter
>using the Startup parameters feature of the service properties.  I figured
>it would pass it to the executable as a command-line parameter but it
>doesn't seem to work like that.  How does my C# code access the service
>start parameters?
>

AddThis Social Bookmark Button