title: Determine the LocalSystem account name using C#
body: <p>We have an application that installs SQL Server Express from the command line and specifies the service account as the LocalSystem account via the parameter SQLACCOUNT="NT AUTHORITY\SYSTEM".</p>
  
  <p>This doesn't work with different languages because the account name for LocalSystem is different. There's a table listing the differences here:</p>
  
  <p><a href="http://forums.microsoft.com/MSR/ShowPost.aspx?PostID=685354&amp;SiteID=37" rel="nofollow noreferrer">http://forums.microsoft.com/MSR/ShowPost.aspx?PostID=685354&amp;SiteID=37</a></p>
  
  <p>This doesn't seem to be complete (the Swedish version isn't listed). So I'd like to be able to determine the name programmatically, perhaps using the SID?</p>
  
  <p>I've found some VB Script to do this:</p>
  
  <pre><code>Set objWMI = GetObject("winmgmts:root\cimv2") 
  
  Set objSid = objWMI.Get("Win32_SID.SID='S-1-5-18'") 
  
  MsgBox objSid.ReferencedDomainName &amp; "\" &amp; objSid.AccountName 
  </code></pre>
  
  <p>Does anyone know the equivalent code that can be used in C#?</p>