Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install Simple Windows Service - Login?

I am trying to create a simple Windows Service based on this walkthrough. When I try to execute the command:

C:\worl\Project Alpha\Code\AlphaBackendService\AlphaBackendService\bin\Debug>ins
tallutil.exe AlphaBackendService.exe

It presents a dialog box with username, Password, Confirm password. Nothing I enter works and the install fails. What account does it want? Why can't I just use anything I type in? IIs it because of the EventLog requiring permission:

 public partial class AlphaBackendService : ServiceBase
 {
        public AlphaBackendService()
        {
            InitializeComponent();
            if (!System.Diagnostics.EventLog.SourceExists("AlphaSource"))
            {
                System.Diagnostics.EventLog.CreateEventSource("AlphaSource", "AlphaLog");
            }
            eventLog1.Source = "AlphaSource";
            eventLog1.Log = "AlphaLog";
        }

        protected override void OnStart(string[] args)
        {
            eventLog1.WriteEntry("In OnStart");
        }

        protected override void OnStop()
        {
            eventLog1.WriteEntry("In OnStop");
        }
 }

enter image description here

like image 649
user2471435 Avatar asked Feb 06 '14 17:02

user2471435


1 Answers

In the ProjectInstaller, set the propery Account to LocalSystem (From designer) or set following code in InitializeComponent() method

        this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
like image 100
M.S. Avatar answered Oct 14 '22 18:10

M.S.