Click here to Skip to main content
13,193,468 members (48,512 online)
Click here to Skip to main content
Add your own
alternative version


26 bookmarked
Posted 16 Jun 2007

Windows Vista BCD

, 16 Jun 2007
Rate this:
Please Sign up or sign in to vote.
An article on the new Windows Vista Boot Environment

Windows Vista BCD Editor


This article will guide you on how to edit Windows Vista Boot Configuration programmatically just like we did with our old friends XP or Windows 2000 by editing the boot.ini file.

1. What is Windows Vista BCD

Old Windows uses boot.ini to configure boot sequences, this boot.ini file will be loaded by ntldr.exe

An old boot.ini looks like this (very familiar, huh?)

Old Boot.ini

BCD is a new boot environment for Windows Vista.
BCD = Boot Configuration Data

2. BCD Hierarchy

BCD hierachy

  • BCD Store: Namespace container for BCD Objects and other elements that make up the contents of a store.
  • BCD Object: Container for BCD Elements. The most common type of BCD Object describes a boot environment.
  • BCD Element: An item of data, i.e. boot application name, OS device …

3. BCD System Store

BCD System Store

So, take a look at the figure.

If you want to manipulate some boot information, you have to access the Windows Boot Manager BCD Object.

Want to show the old friend boot.ini file? Access the Legacy Boot Loader. Pretty simple, huh ?

4. How do we access BCD in .NET

In .NET, there's a namespace called System.Management, which provides classes for managing information and events about the system, devices, and applications instrumental to the Windows Management Instrumentation (WMI) infrastructure.

We can manually use System.Management's classes to manipulate BCD data, by using ManagementClass, ManagementObject … classes … but it's not a good idea.

We will use some tricks here. We will create all the classes representing BCDStore, BCDObject, BCDElement … (all these classes make used of ManagementClass, ManagementObject … of course) but we'll create it automatically by using a tool.

5. Generate classes by using mgmtclassgen.exe

There's a file called bcd.mof in the path system32\wbem. This file contains all the information we need to generate BCD classes.

And we'll use the mgmtclassgen.exe tool to generate these classes (this tool comes with Visual Studio .NET).

OK, enough talking. Let's have some fun with the new Windows Vista BCD.

6. Step by Step demo

We'll create an application that allows users to change the name of the OS display in the load screen and set the timeout value (these tasks were very easy with the old friend boot.ini)

I. Start Visual Studio 2005 and create a new Windows Application. Design the GUI.

Our application

II. Create BCD classes

Go to the Visual Studio 2005 Command Prompt, execute the command: mgmtclassgen BcdStore /N root\WMI /L CS to generate BcdStore class in Csharp language, namespace root\WMI (BcdStore class resides in this namespace)

Similar for BcdObject, BcdElement

Classes generate

After this step, you'll have all the classes you need in the .cs files.

III. Reference System.Management.dll and add all the .cs files you have created in step II to your project.

Add a reference to the COM components named Microsoft BCD constants library to get all the constants pre-defined for BCD (that you don't need to define manually).

BCD Constants COM

IV. Samples code

Example code to load all OS to listbox:

ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.Impersonation = ImpersonationLevel.Impersonate;
connectionOptions.EnablePrivileges = true;

ManagementScope managementScope = new ManagementScope(@"root\WMI", 

// SYSTEM STORE GUID = {9dea862c-5cdd-4e70-acc1-f32b344d4795}
BcdObject systemObject = new BcdObject(managementScope, 
            "{9dea862c-5cdd-4e70-acc1-f32b344d4795}", "");

ManagementBaseObject mboOut;
bool success = systemObject.GetElement((uint)
     out mboOut);

if (success)
    string[] osIdList = (string[])mboOut.GetPropertyValue("Ids");
         // LOOP FOR ALL OS Ids (GUID)
         foreach (string osGuid in osIdList)
              BcdObject osObj = new BcdObject(managementScope, osGuid, "");
              success = osObj.GetElement((uint)
         out mboOut);

              if (success)
                  OS myOS = new OS();
                  myOS.Name = mboOut.GetPropertyValue("String").ToString();
                  myOS.GUID = osGuid;
Example code to set a new description for OS:

BcdObject osObj = ((OS)lstOS.SelectedItem).osObj;

Simple, huh?


The links below will be very helpful for you to understand this article:


  • First version, no updates!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tran Dinh Hop
Vietnam Vietnam
Started my first .NET application 5 years ago.
2 years worked with VC++
Currently : Hanoi Aptech Computer Education Trainer

You may also be interested in...

Comments and Discussions

QuestionCannot find the "Microsoft BCD Constants Library" Pin
Member 1097649813-Aug-14 10:32
memberMember 1097649813-Aug-14 10:32 
GeneralInvalid Class (XP) Pin
starbase23110-Apr-10 9:54
memberstarbase23110-Apr-10 9:54 
GeneralHehehe Pin
Acgiuna2-Jul-09 4:39
memberAcgiuna2-Jul-09 4:39 
GeneralHelp on BCD Pin
xero92006-Sep-08 8:21
memberxero92006-Sep-08 8:21 
GeneralRe: Help on BCD Pin
Tran Dinh Hop7-Sep-08 1:13
memberTran Dinh Hop7-Sep-08 1:13 
QuestionRead Vista BCD file from Windows XP Pin
paragcoder3-Oct-07 23:38
memberparagcoder3-Oct-07 23:38 
AnswerRe: Read Vista BCD file from Windows XP Pin
theMadCoder7-Mar-12 8:22
membertheMadCoder7-Mar-12 8:22 
GeneralConfirms what I though about the Vista designers! Pin
Bob100018-Jun-07 12:57
memberBob100018-Jun-07 12:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171018.2 | Last Updated 16 Jun 2007
Article Copyright 2007 by Tran Dinh Hop
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid