用VS制作的windows服务安装包 安装完后如何让服务自动启动

vs 服务做成安装包,如何安装以后启动服务,只要在类名为projectinstaller的类中重写commit事件即可
    
   public override void Commit(IDictionary savedState)
        {
            base.Commit(savedState);

            ServiceController sc = new ServiceController("HttpProviderService");
            if (sc.Status.Equals(ServiceControllerStatus.Stopped))
            {
                sc.Start();
            }
        } 

 

 

 

posted @ 2019-02-19 16:36  龙骑科技  阅读(703)  评论(0编辑  收藏  举报