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

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?
 
A

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top