I tried to pass parameters to a windows service.
Here is my code snippet:
class Program : ServiceBase
{
public String UserName { get; set; }
The two cleanest ways to pass arguments (without using registry, files or a database) to a Windows Service at runtime is using Named Pipes or setting up a WCF Service in windows, that your client calls into. By default, a Windows Service is meant to be a repetitive process that runs.
If you use WCF, turn it on in Add Remove Programs (or Programs and Features for Windows 7).
Named Pipes:
https://msdn.microsoft.com/en-us/library/aa365590(v=vs.85).aspx