Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Using VBScript and WMI to Access Vista's BcdStore

0.00/5 (No votes)
1 Apr 2007 1  
An example showing how to use VBScript and WMI to access Vista's BcdStore.

Introduction

Vista's BCD (Boot Configuration Data) replaces the boot.ini file used in previous Windows versions. The primary audience for this script is a system Administrator who needs to automate some aspect of how a Vista machine boots.

Microsoft does provide documentation on how to examine and update the BcdStore (i.e. the registry file that contains the BCD), but the information is spread over several sources. There are few decent examples of using VBScript to examine or update BcdStore information.

This script is intended as a working sample that can be used as a starting point to provide some automation. By replicating the output of the "bcdedit /enum active" command, people can see how to extract boot-related information.

Background

WMI is a large and complicated topic. For readers unfamiliar with WMI, I would recommend this  URL as a good introduction in what WMI is, and how to use it with VBScript.

Microsoft's documentation for BCD can be found in:

  1. Vista Software Development Kit
  2. MSDN Library, "Boot Configuration Data (BCD)" 
  3. "Boot Configuration Data in Windows Vista"

Using the Code

The script displays lines of text, similar to Vista's "bcdedit.exe" command line utility. Therefore the program should be run as a cscript:

cscript mimic_bcedit.vbs 

Alternatively, you can set your default scripting host to cscript by issuing the command:

cscript //h:cscript 

In this case, the leading cscript can be omitted when you run any .vbs file.

Points of Interest

The BCD stores logical drive information in the form:

\Device\HarddiskVolumeX 

Unfortunately there is no simple way (that I know of) to convert that to a drive letter (e.g. C:) using VBScript. The DDK function ZwQuerySymbolicLinkObject() can be used to obtain the drive letter from a \Device\HarddiskVolumeX reference.

History

  • Uploaded on April 1, 2007 - Initial version

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here