title: How can you remotely login to a remote computer using C#?
body: <p>I'm trying to write a small command line application with C# that will prompt for a username and a password that will be used to login to several remote computers that are sitting on the same network/domain and start a local session.</p>
  
  <p>I've tried connecting to a remote computer and to query the remote PC's operating system info with the following code:</p>
  
  <pre><code>ConnectionOptions options = new ConnectionOptions();
  
  ManagementScope scope = new ManagementScope(@"\\REMOTE_COMPUTER_NAME");
  scope.Connect();
  
  ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
  ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
  
  ManagementObjectCollection queryCollection = searcher.Get();
  
  foreach (ManagementObject m in queryCollection)
  {
      // Display the remote computer information
      Console.WriteLine("Computer Name : {0}", m["csname"]);
      Console.WriteLine("Windows Directory : {0}", m["WindowsDirectory"]);
      Console.WriteLine("Operating System: {0}", m["Caption"]);
      Console.WriteLine("Version: {0}", m["Version"]);
      Console.WriteLine("Manufacturer : {0}", m["Manufacturer"]);
  }
  </code></pre>
  
  <p>However, this only returns information on the local PC that I'm working on and not on the remote PC. </p>
  
  <p>Am I overlooking something with this code? And is there an appropriate approach to accomplish what I am trying to do?</p>