【问题标题】:Ensure that the service is automatically started immediately after installation确保安装后立即自动启动服务
【发布时间】:2014-03-27 11:05:08
【问题描述】:

我有一个正在使用 installutil.exe 安装的 Windows 服务。如何确保安装后立即自动启动服务。这是服务 ProjectInstaller 类

using System.ComponentModel;

namespace MedicalService_WindowsService
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
        public ProjectInstaller()
        {
            InitializeComponent();
        }
    }
}

【问题讨论】:

    标签: c# service installutil


    【解决方案1】:

    使用ServiceInstaller。将StartType 设置为Automatic。这将确保服务自动启动,但不会实际启动服务。为此,在服务安装完成后,使用ServiceController.Start() 显式启动服务。

    【讨论】:

      猜你喜欢
      • 2010-11-14
      • 2016-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-26
      • 2019-03-01
      • 2020-08-22
      • 1970-01-01
      相关资源
      最近更新 更多