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

  • Thread starter Thread starter Jen
  • Start date Start date
J

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?
 
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.
 
Back
Top