Couple of questions regarding Windows Service in C#
-
Hi, I am developing a Windows service in C#. I have couple of question on that. 1. Is it possible to set a Start up parameter during installation of the service? I know that I can pass a parameter while calling ServiceController.Start() method. But the service start type is Autometic and I want the service to run everytime with the same parameter. 2. Is it possible to uninstall the service from within. Say if I meet certain criteria in the service work flow, I want to uninstall the service. Is it possible? Thanks.
-
Hi, I am developing a Windows service in C#. I have couple of question on that. 1. Is it possible to set a Start up parameter during installation of the service? I know that I can pass a parameter while calling ServiceController.Start() method. But the service start type is Autometic and I want the service to run everytime with the same parameter. 2. Is it possible to uninstall the service from within. Say if I meet certain criteria in the service work flow, I want to uninstall the service. Is it possible? Thanks.
Aryan S wrote:
1. Is it possible to set a Start up parameter during installation of the service? I know that I can pass a parameter while calling ServiceController.Start() method. But the service start type is Autometic and I want the service to run everytime with the same parameter.
Store the parameters in the Registry or in a config file somewhere.
Aryan S wrote:
2. Is it possible to uninstall the service from within. Say if I meet certain criteria in the service work flow, I want to uninstall the service. Is it possible?
I've never heard of a service uninstalling itself. Doesn't mean it's not possible though.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
Hi, I am developing a Windows service in C#. I have couple of question on that. 1. Is it possible to set a Start up parameter during installation of the service? I know that I can pass a parameter while calling ServiceController.Start() method. But the service start type is Autometic and I want the service to run everytime with the same parameter. 2. Is it possible to uninstall the service from within. Say if I meet certain criteria in the service work flow, I want to uninstall the service. Is it possible? Thanks.
- Store it somewhere -- I use a database 2) I doubt it; you can't uninstall a running Service ... but maybe you could Start a Process that will stop and uninstall the Service.