0

Previously when I have created Windows services in .NET, I create the application so that it can run as a service or as an interactive application (it identifies how it should run depending on the presence of a command line argument - for instance --service.

I am looking at using TopShelf, and wonder if this has this functionality. I haven't yet found anything, but wonder if anyone knows?

Lee Atkinson
  • 2,171
  • 3
  • 20
  • 32

1 Answers1

1

When a Topshelf service is run, the context is automatically handled. Just run it without any parameters and it runs as a console application. When you execute myService.exe install it will setup everything that's needed to run as service. You just execute the service via the service manager then.

Travis
  • 10,444
  • 2
  • 28
  • 48
  • Thanks - can I still pass parameters for my own use - and what parameters does TopShelf 'reserve' for its own user - e.g. install? – Lee Atkinson Sep 10 '12 at 16:33
  • Topshelf attempts to parse all the parameters, I don't think you can pass any. If you need to configure it that way normally we would suggest leveraging the app.config. http://docs.topshelf-project.com/en/latest/overview/commandline.html – Travis Sep 10 '12 at 19:43
  • In current versions you can now use `x.AddCommandLineDefinition(...)` within your HostFactory.New() or .Run() – SteveM May 01 '13 at 22:34