Console

控制台应用程序

启动选项->命令行参数" 指定为任意字符串,如: "/cxxx"

static void Main(string[] args )
{
    Service1 x = new Service1();
    if (args.Length > 0)
    {
        Console.WriteLine("Console");
        x.OnStart(null);
        Console.ReadLine();
    }
    else
    {
        System.ServiceProcess.ServiceBase[] ServicesToRun;
        // 同一进程中可以运行多个用户服务。若要将
        //另一个服务添加到此进程,请更改下行
        // 以创建另一个服务对象。例如,
        //
        //   ServicesToRun = New System.ServiceProcess.ServiceBase[] {new Service1(), new MySecondUserService()};
        //
        ServicesToRun = new System.ServiceProcess.ServiceBase[] { x};
        System.ServiceProcess.ServiceBase.Run(ServicesToRun);
    }
}

  命令行编译:
csc service1.cs

cmd 命令行状态 service1.exe /xxx

EditPlus

原文地址:https://www.cnblogs.com/xiangxiong/p/7753748.html