What I am trying to do, i have an executable file (myService.exe). it is a windows service and it supports start, stop and other such options. It uses one argument (filename) and run its survices on it. e.g. c:\myService.exe someFileName.dat
now i am making a c# windows form application. I am reading filename from a textbox and on button click event i want to do this.
- check whether myServices.exe is installed on machine or not.
- if it is installed then i have to check it is in running state or not.
- if it is in running state then stop it.
- after stopping it i need to uninstall the service.
- after uninstalling it i want to install it again and have to give filename as the parameter of service and then run it.
How to install a windows service programmatically in C#? i have tried this but i have to give argument to the service which is not present there.