title: Start process as system user
body: <p>I was trying to read some values from some registry keys with code (c#) on windows and I found out that the reason why I was not able to read the values was because the admin user did not had permissions: </p>
  
  <p>So I manually navegated to the registry key that was giving me trouble and this is how the permissions tab looked like:</p>
  
  <p><img src="https://i.stack.imgur.com/NFFsd.png" alt="enter image description here"></p>
  
  <p>So that made me thought about how can I run a process as the user "system"? That sounds weird but apparently there is a system user right? I know how to run as administrator but maybe it is also possible to run as system. </p>
  
  <h2>Edit</h2>
  
  <p>here is my code. Basically I will like to traverse through all the registry keys:</p>
  
  <pre><code>class Program
  {
      // class to store reg key.
      [Serializable]
      [DebuggerDisplay("Name = {Name}, Val = {value}, type={type}")]
      class MyRegKey
      {
          public string Name;
          public object value;
          public RegistryValueKind type;
          public List&lt;MyRegKey&gt; SubKeys = new List&lt;MyRegKey&gt;();
          public List&lt;MyRegKey&gt; Values = new List&lt;MyRegKey&gt;();
      }
  
      static MyRegKey root = new MyRegKey();
  
      static void TraverseTree(RegistryKey key, MyRegKey temp)
      {
          foreach (var v in key.GetValueNames())
          {            
              var kind = key.GetValueKind(v);
              var value = key.GetValue(v, null);
              var name = v;
  
              temp.Values.Add(new MyRegKey { Name = name, value = value, type = kind });
          }
  
          var x = key.GetSubKeyNames();
          for (var i = 0; i &lt; x.Length; i++)
          {
              RegistryKey productKey;
              productKey = key.OpenSubKey(x[i], false); // &lt;--------- Code crashes here
  
              if (productKey != null)
              {
                  var y = new MyRegKey() { Name = productKey.Name };
                  temp.SubKeys.Add(y);
                  Foo(productKey, y);
              }
          }        
      }
  
      public static void Main()
      {
  
          var key = Registry.LocalMachine;
  
          root.Name = key.Name;
          TraverseTree(key, root);
      }
  }
  </code></pre>
  
  <p>I am running that code as an administrator...</p>
  
  <p>And here is an image of how my program crashes stating that I don't have permissions:
  <img src="https://i.stack.imgur.com/Yq92U.png" alt="enter image description here"></p>