title: Windows Service calls Command Line Application which requires user logged in
body: <p>I have an issue where my Windows Service is running a 3rd Party Command Line Application.</p>
  
  <p>This works fine however, the Command Line Application attempts to access HKEY_CURRENT_USER registry keys.  So the command line throws the following exception:</p>
  
  <pre><code>System.IO.IOException: Illegal operation attempted on a registry key that has been marked for deletion. 
  
  at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str) 
  at Microsoft.Win32.RegistryKey.SetValue(String name, Object value, RegistryValueKind valueKind) 
  at Microsoft.Win32.RegistryKey.SetValue(String name, Object value) 
  at ACMEApp.Settings.GetValue(String name, Object def) in SomeClass.cs:line 542 
  </code></pre>
  
  <p>The service is configured to run under a dedicated domain user account (with Admin privileges on the machine).</p>
  
  <p>I have a workaround for this which is to leave the user the service runs under logged in to the machine.  This is far from ideal.  Other users have logged on to the machine and logged this user off causing the issue to reappear.  I cant make the third party change their code although it was meant to be able to be run from my service.  This also hangs the console application.</p>
  
  <p>I need some thought on how to tackle this one.  Is there a way to just make it work (magic) or better to make error reporting more obvious?  </p>
  
  <p>At the moment the service just logs to a log file where as the failure points are when the users report things have not worked.</p>