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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
You can use the
ChangeServiceConfigAPI to change this (MSDN docs here, PInvoke here). I think you might also be able to change this as one of the settings of theInstaller.Contextproperty (described here), possibly calledAssemblyPathor 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.