title: How to make Windows Service start as "Automatic (Delayed Start)"
body: <p><strong>Scenario:</strong></p>
  
  <p>A WCF service running as a Windows Service. Account is "User".</p>
  
  <hr>
  
  <p><strong>What is done:</strong></p>
  
  <p>I have overridden the OnBeforeInstall in the projectinstaller to be able to set username and password from a config file.</p>
  
  <hr>
  
  <p><strong>What I would be able to do:</strong></p>
  
  <p>I'd like to be able to set the starttype as Automatic (Delayed Start)</p>
  
  <hr>
  
  <p><strong>What I have tried:</strong></p>
  
  <p>I put the following coderow in the overridden OnBeforeInstall</p>
  
  <p><code>serviceInstaller1.StartType = ServiceStartMode.Automatic + 1;</code></p>
  
  <p>Figured I would trick the ServiceStartMode enum into representing Automatic (Delayed Start), didn't work. Haven't tried anything more simply because I couldn't find anything to try.</p>
  
  <hr>
  
  <p><strong>What I have found on the net:</strong></p>
  
  <p>I found out that Automatic (Delayed Start) will be available in .NET 4, but that doesn't help me right now.
  <a href="http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.delayedautostart%28VS.100%29.aspx" rel="noreferrer">MSDN</a>
  I found out that DelayedAutoStart could be added to the service's configuration key, but this feels like a hack if I should do this from code. But maybe this is the only solution available for me at this point?</p>
  
  <ul>
  <li><a href="http://blogs.technet.com/askperf/archive/2008/02/02/ws2008-startup-processes-and-delayed-automatic-start.aspx" rel="noreferrer">WS2008: Startup Processes and Delayed Automatic Start</a></li>
  </ul>
  
  <p><em>Any ideas?</em></p>
  
  <p>Robert Persson, Sweden</p>