Installing a Topshelf application as a Windows service

后端 未结 4 1759
离开以前
离开以前 2020-12-23 16:12

Using Visual Studio Express 2012, I\'ve created a console application using Topshelf (Version 3.1.107.0). The application works as a console application, but I can\'t figure

4条回答
  •  半阙折子戏
    2020-12-23 16:27

    So this is an old question, but I want to add some command line options.

    MyTopShelfImplementation.exe install -servicename "MyServiceName" -displayname "My Display Name" --autostart start

    .

    --autostart

    is for when windows reboots.

    start

    is for starting the service IMMEDIATELY after you install it

    Now, the "names" you can also specify in code

                HostFactory.Run(x =>
                {
                    ////x.SetDescription("My Description");
                    x.SetDisplayName("My Display Name");
                    x.SetServiceName("My Service Name");
                    ////x.SetInstanceName("My Instance");
    

    So if the .exe runs as console app (or as windows service) may be some combination of setting these values in code and/or passing them in via the command line.

    I would expect if you did not set the "names" in code AND you did not pass the "names" in by command line args, then you'll get console behavior.

提交回复
热议问题