Using startupparameters in Windowsservice?

I'm writing a Windows Service in Visual Studio 2005.

When rightclicking a service in Windows and choosing properties there is a textbox for startup parameters. How can I detect those startupparameters in my service I've tried using My.Application.CommandLineArgs, but it doesn't seem like it is the same.


Answer this question

Using startupparameters in Windowsservice?

  • Regerio R. Alcantara

    The startup parameters are passed as a string array to the OnStart method of the Service. You can use these exactly as you can in a Console application.

    If you didn't created the service from a the Windows Service Template, you'll need to override the OnStart method of the service. (in the class that inherits from ServiceBase)

    Protected Overrides Sub OnStart(ByVal args() As String)

    MyBase.OnStart(args)

    'process the args...

    End Sub



  • Using startupparameters in Windowsservice?