title: Windows Service start from logged in user c#
body: <p>I made a windows service (which is working), but it is running on the SYSTEM user and I want it to run on my current logged in user. </p>
  
  <p>Here is my service installer class:</p>
  
  <pre><code>[RunInstaller(true)]
  class CloudManagerServiceInstaller : Installer
  {
      public CloudManagerServiceInstaller()
      {
          var serviceInstaller = new ServiceInstaller();
          var serviceProcessInstaller = new ServiceProcessInstaller();
  
          serviceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.User;
          serviceProcessInstaller.Username = Environment.MachineName + "\\carl";
  
          serviceInstaller.DisplayName = "Z";
          serviceInstaller.StartType = ServiceStartMode.Manual;
  
          serviceInstaller.ServiceName = "Z";
  
          this.Installers.Add(serviceInstaller);
          this.Installers.Add(serviceProcessInstaller);
      }
  
  }
  </code></pre>
  
  <p>And there is my servicebase:</p>
  
  <pre><code>class CloudManagerServiceBase : ServiceBase
  {
      public int i = 0;
      private System.Timers.Timer _timer;
      private int m = 2;
      public CloudManagerServiceBase()
      {
          this.ServiceName = "ZSCloudManager";
      }
  
      protected override void OnStart(string[] args)
      {
          base.OnStart(args);
  
          _timer = new System.Timers.Timer(m * 60 * 1000); // every m minutes
          _timer.Elapsed += _timer_Elapsed;
          _timer.Start(); // &lt;- important
  
  
  
      }
  
      void _timer_Elapsed(object sender, ElapsedEventArgs e)
      { do work }}
  </code></pre>
  
  <p>I install the service with the help of another progamm.
  Can I write the service like that or do I have to follow these instructions -> <a href="http://blogs.msdn.com/b/winsdk/archive/2009/07/14/launching-an-interactive-process-from-windows-service-in-windows-vista-and-later.aspx" rel="nofollow">http://blogs.msdn.com/b/winsdk/archive/2009/07/14/launching-an-interactive-process-from-windows-service-in-windows-vista-and-later.aspx</a>
  If thats the case then can you please give me a code snippet, because i dont fully understand this.</p>