title: C# How to change the drive letter of the CDROM from D: to Z:
body: <p>I am trying to write a metod that will change the CDROM drive from letter D to letter Z and not having any luck with WMI. Is there some other way that I can do this using C#?</p>
  
  <pre><code>public void setVolCDROM()
  {
      SelectQuery queryCDROM = 
          new SelectQuery("SELECT * FROM Win32_cdromdrive");
      ManagementObjectSearcher searcherCDROM = 
          new ManagementObjectSearcher(queryCDROM);
      foreach(ManagementObject cdromLetter in searcherCDROM.Get())
      {
          MessageBox.Show(cdromLetter["Drive"].ToString() + "\n"
              + cdromLetter["Manufacturer"].ToString());
          if (cdromLetter["Drive"].ToString() == "D:")
          {
              cdromLetter["Drive"] = "Z:";                        
              cdromLetter.Put();
          }
      }
  }
  </code></pre>