Skip to content

Instantly share code, notes, and snippets.

@bigtan
Created May 30, 2017 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigtan/3ea78a29a79ea4f272a44fa90bc1df39 to your computer and use it in GitHub Desktop.
Save bigtan/3ea78a29a79ea4f272a44fa90bc1df39 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using Topshelf;
namespace CowService
{
public class ProxyProcess
{
readonly Process proxy;
public ProxyProcess()
{
proxy = new Process();
proxy.StartInfo.FileName = "cow.exe";
proxy.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
}
public void Start() { proxy.Start(); }
public void Stop() { proxy.Kill(); }
}
class Program
{
static void Main(string[] args)
{
HostFactory.Run(x =>
{
x.Service<ProxyProcess>(s =>
{
s.ConstructUsing(name => new ProxyProcess());
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc => tc.Stop());
});
x.RunAsLocalSystem();
x.StartAutomatically();
x.SetDescription("Shadowsocks client cow.");
x.SetDisplayName("cow");
x.SetServiceName("cow");
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment