Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add commandline arguments to service installer c#

I am working on an application which starts as a service but only if a commandline switch tells it to (otherwise a standard form is opened). So when the service is started by Windows at bootup, it must pass this commandline option or the service fails to start.

I would like to have the installer (ServiceProcessInstaller) add a commandline option so that when the service is started it adds the commandline option to the command.

Example: MyService.exe -commandlineoption

I thought this was what the ServiceProcessorInstaller.Context property was for, but that is for the arguments that were executed on InstallUtil.

Any suggestions?

like image 862
Tim Avatar asked Nov 14 '22 15:11

Tim


1 Answers

When I've added command-line options to services, I've always defaulted to running as a service. However, I know that the opposite is possible because it's how SvcHost works: it's an EXE that's always configured to load DLL's as services.

like image 150
Steven Sudit Avatar answered Dec 29 '22 01:12

Steven Sudit