public static bool DeleteOsEntry(string osEntryId, string storePath) { ROOT.WMI.BcdStore bcdStore = new ROOT.WMI.BcdStore(BcdStore_API.ImpersonationScope, storePath); bool bTestResult = bcdStore.DeleteObject(osEntryId); return(bTestResult); }
public static bool CreateNewOSEntry(BcdStore_API.OSEntryTypes osEntryType, string storePath, out string newGuidOut) { newGuidOut = ""; // default to empty guid for failure ROOT.WMI.BcdStore bcdStore = new ROOT.WMI.BcdStore(BcdStore_API.ImpersonationScope, storePath); string newGuid = "{" + Guid.NewGuid().ToString() + "}"; ManagementBaseObject newObject; bool success; if (osEntryType == OSEntryTypes.Legacy) { success = bcdStore.CreateObject(newGuid, Constants.BCDE_LEGACY_OS_ENTRY, out newObject); } else { success = bcdStore.CreateObject(newGuid, Constants.BCDE_VISTA_OS_ENTRY, out newObject); } if (success) { newGuidOut = newGuid; } return(success); }
public static List <string> EnumerateObjectsByType(uint bcdType, string storePath) { List <string> objectGuidList = null; ROOT.WMI.BcdStore bcdStore = new ROOT.WMI.BcdStore(BcdStore_API.ImpersonationScope, storePath); ManagementBaseObject[] mboArray; bool success = bcdStore.EnumerateObjects(bcdType, out mboArray); if (success) { objectGuidList = new List <string>(); foreach (ManagementBaseObject mbo in mboArray) { objectGuidList.Add((string)mbo.GetPropertyValue("Id")); } } return(objectGuidList); }
public static bool CloneExistingOSEntry(string osEntryToCloneGuid, string newOSEntryDescriptionName, string storePath, out string errorDetails) { errorDetails = string.Empty; // default error string to empty string/no errors ROOT.WMI.BcdStore bcdStore = new ROOT.WMI.BcdStore(BcdStore_API.ImpersonationScope, storePath); string newGuid = "{" + Guid.NewGuid().ToString() + "}"; ManagementBaseObject newObject; bool success = bcdStore.CopyObject(Constants.BCD_COPY_CREATE_NEW_OBJECT_IDENTIFIER, osEntryToCloneGuid, storePath, out newObject); if (!success) { errorDetails = "failure with bcdstore copy object call"; return(false); } BcdObject newBcdObject = new BcdObject(newObject); string newGuid2 = newBcdObject.Id.ToString(); if (success) { string errorString; bool successfulAddToOsList = AddGuidToOSDisplayList(newGuid2, storePath, out errorString); if (!successfulAddToOsList) { errorDetails = errorString; return(false); } bool setDescripStatus = ChangeOSEntryDescription(newBcdObject.Id, newOSEntryDescriptionName, storePath); if (!setDescripStatus) { errorDetails = "failure with setting new OS entry description, otherwise success"; return(false); } } return(true); }
public BcdStore(System.Management.ManagementScope mgmtScope, string keyFilePath) { this.InitializeObject(((System.Management.ManagementScope)(mgmtScope)), new System.Management.ManagementPath(BcdStore.ConstructPath(keyFilePath)), null); }
public BcdStore(string keyFilePath) { this.InitializeObject(null, new System.Management.ManagementPath(BcdStore.ConstructPath(keyFilePath)), null); }
public static List<string> EnumerateObjectsByType( uint bcdType, string storePath ) { List<string> objectGuidList = null; ROOT.WMI.BcdStore bcdStore = new ROOT.WMI.BcdStore(BcdStore_API.ImpersonationScope, storePath); ManagementBaseObject[] mboArray; bool success = bcdStore.EnumerateObjects(bcdType, out mboArray); if (success) { objectGuidList = new List<string>(); foreach (ManagementBaseObject mbo in mboArray) { objectGuidList.Add((string)mbo.GetPropertyValue("Id")); } } return objectGuidList; }
public static bool DeleteOsEntry(string osEntryId, string storePath) { ROOT.WMI.BcdStore bcdStore = new ROOT.WMI.BcdStore(BcdStore_API.ImpersonationScope, storePath); bool bTestResult = bcdStore.DeleteObject(osEntryId); return bTestResult; }
public static bool CreateNewOSEntry(BcdStore_API.OSEntryTypes osEntryType, string storePath, out string newGuidOut) { newGuidOut = ""; // default to empty guid for failure ROOT.WMI.BcdStore bcdStore = new ROOT.WMI.BcdStore(BcdStore_API.ImpersonationScope, storePath); string newGuid = "{" + Guid.NewGuid().ToString() + "}"; ManagementBaseObject newObject; bool success; if (osEntryType == OSEntryTypes.Legacy) success = bcdStore.CreateObject(newGuid, Constants.BCDE_LEGACY_OS_ENTRY, out newObject); else success = bcdStore.CreateObject(newGuid, Constants.BCDE_VISTA_OS_ENTRY, out newObject); if (success) { newGuidOut = newGuid; } return success; }
public static bool CloneExistingOSEntry(string osEntryToCloneGuid, string newOSEntryDescriptionName, string storePath, out string errorDetails) { errorDetails = string.Empty; // default error string to empty string/no errors ROOT.WMI.BcdStore bcdStore = new ROOT.WMI.BcdStore(BcdStore_API.ImpersonationScope, storePath); string newGuid = "{" + Guid.NewGuid().ToString() + "}"; ManagementBaseObject newObject; bool success = bcdStore.CopyObject(Constants.BCD_COPY_CREATE_NEW_OBJECT_IDENTIFIER, osEntryToCloneGuid, storePath, out newObject); if (!success) { errorDetails = "failure with bcdstore copy object call"; return false; } BcdObject newBcdObject = new BcdObject(newObject); string newGuid2 = newBcdObject.Id.ToString(); if (success) { string errorString; bool successfulAddToOsList = AddGuidToOSDisplayList(newGuid2, storePath, out errorString); if (!successfulAddToOsList) { errorDetails = errorString; return false; } bool setDescripStatus = ChangeOSEntryDescription(newBcdObject.Id, newOSEntryDescriptionName, storePath); if (!setDescripStatus) { errorDetails = "failure with setting new OS entry description, otherwise success"; return false; } } return true; }