Exemplo n.º 1
0
 ///<summary>Gets the boot order for the specified virtual machine.</summary>
 ///<param name="name">The name of the virtual machine.</param>
 public BootEntries GetVirtualMachineBootOrder(string name)
 {
     using (ManagementObject virtualMachine = GetVirtualMachine(name))
         using (ManagementObject systemSettings = GetRelatedSettings(virtualMachine, Settings.System))
         {
             BootEntries bootEntries = new BootEntries();
             foreach (string bootEntry in (string[])systemSettings["BootSourceOrder"])
             {
                 bootEntries.Add(new BootDevice(bootEntry));
             }
             return(bootEntries);
         }
 }
Exemplo n.º 2
0
        ///<summary>Sets the boot order for the specified virtual machine.</summary>
        ///<param name="name">The name of the virtual machine.</param>
        ///<param name="bootOrder">The new boot order.</param>
        public void SetVirtualMachineBootOrder(string name, BootEntries bootOrder)
        {
            using (ManagementObject virtualMachine = GetVirtualMachine(name))
                using (ManagementObject systemSettings = GetRelatedSettings(virtualMachine, Settings.System))
                {
                    List <string> bootEntries = new List <string>();
                    foreach (BootDevice bootEntry in bootOrder)
                    {
                        bootEntries.Add(bootEntry.ToString());
                    }
                    systemSettings["BootSourceOrder"] = bootEntries.ToArray();

                    ModifySystemSettings(systemSettings);
                }
        }