Is it possible to programatically set the "Start Parameters" on a Windows Service at install time?
EDIT
This isn't actually possible. However, you can edit the image path as per ho1's instructions.
Is it possible to programatically set the "Start Parameters" on a Windows Service at install time?
EDIT
This isn't actually possible. However, you can edit the image path as per ho1's instructions.
If you're able to produce a deployment for each configuration and you want your parameters configured at "install time" (that is, once only and not per-start up) then perhaps you should simply use an App.config and some AppSettings.
Edit: I misunderstood the question so here's my new answer.
I think those parameters are only for using while actually starting the service manually from the services applet. I don't think those are an actual setting that are stored anywhere.
The closest thing to that would be to add some parameters after the service exe name in the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\[YourService]\ImagePath
You can use the ChangeServiceConfig
API to change this (MSDN docs here, PInvoke here). I think you might also be able to change this as one of the settings of the Installer.Context
property (described here), possibly called AssemblyPath
or similar.
I'm not sure if parameters set this way might appear to the main function rather than the OnStart though (I think start parameters go to OnStart), so it might not be exactly what you're looking for but hopefully it'll give you some ideas.