Skip to content

brokeree/launchable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status

Launchable

Easily install your .NET console apps as windows services. Internally uses sc to install, uninstall, modify, start and stop services.

Uses entry assembly's:

  • name for the service name (spaces get replaced by -)
  • AssemblyTitleAttribute for the service display name
  • AssemblyDescriptionAttribute for the service description

Sample

using System;
using System.IO;

namespace Launchable.Sample
{
    class Program : ILaunchable
    {
        public void Dispose()
        {
            Log("Stopping");
        }

        public void Start()
        {
            Log("Starting");
        }

        private static void Log(string msg)
        {
            msg = DateTime.Now.ToString("R") + " / " + msg;
            Console.WriteLine(msg);
            File.AppendAllText("log.txt", msg + Environment.NewLine);
        }

        static void Main(string[] args)
        {
            LaunchableRunner.Run<Program>(args);

            // or

            LaunchableRunner.Run(() => new Program(), args);
        }
    }
}

About

Easily install your console apps as services

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages