2016-10-11 75 views
1

我目前有一個程序可以正確安裝爲服務,但啓動類型設置爲「手動」。我如何設置此應用程序啓動類型=自動?C#安裝服務並設置爲在啓動時自動啓動

​​3210

和JMS是:

namespace JMS { 
partial class DocLogicJMS { 
    /// <summary> 
    /// Required designer variable. 
    /// </summary> 
    private System.ComponentModel.IContainer components = null; 

    /// <summary> 
    /// Clean up any resources being used. 
    /// </summary> 
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
    protected override void Dispose(bool disposing) { 
     if (disposing && (components != null)) { 
      components.Dispose(); 
     } 
     base.Dispose(disposing); 
    } 

    #region Component Designer generated code 

    /// <summary> 
    /// Required method for Designer support - do not modify 
    /// the contents of this method with the code editor. 
    /// </summary> 
    private void InitializeComponent() { 
     this.ServiceName = "DocLogic JMS"; 
    } 

    #endregion 
} 

}

回答

0

看來這個問題已經被在這裏找到答案: How do I change a Windows Service's startup type in .NET (post-install)?

這似乎是最upvoted答案:

var svc = new ServiceController("ServiceNameGoesHere"); 
ServiceHelper.ChangeStartMode(svc, ServiceStartMode.Automatic); 
+0

我添加了更多關於我的問題的信息。我認爲這接近我需要但不完全。 –

+0

但你確實把我放在了正確的軌道上。謝謝。我需要這些行:this.JMSserviceInstaller.StartType = ServiceStartMode.Automatic; this.JMSserviceInstaller.DelayedAutoStart = false; –

相關問題