Fixing Bootable VHD

Illustration

I have installed Windows 7 to VHD (Virtual Disk) file a while back now. I did like it, so I killed Vista and decided to install Windows 7 on my primary partition also. During installation of it, I formatted boot partition. Unfortunately, that also killed any possibility to boot into Windows 7 system within virtual disk file.

In order to boot from this disk image, some play with bcdedit is needed (in elevated prompt). First we need to discover identifier of our original installation (marked red in following text). Once we have it, we can make a copy and perform all further editing on newly created entry (marked blue). Then we set device and osdevice settings. With that step, we are ready for booting. Here are exact commands that worked for me:

C:\bcdedit /v
...
Windows Boot Loader
-------------------
identifier       {2fae45a6-f1ca-11dd-bde6-c5438ada3082}
device           partition=C:
path             \Windows\system32\winload.exe
description      Windows 7
locale           en-US
inherit          {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
recoverysequence {2fae45a7-f1ca-11dd-bde6-c5438ada3082}
recoveryenabled  Yes
osdevice         partition=C:
systemroot       \Windows
resumeobject     {2fae45a5-f1ca-11dd-bde6-c5438ada3082}
nx               OptIn


C:\bcdedit /copy "{original_id}" /d "Windows 7 VHD"
The entry was successfully copied to {2fae45a9-f1ca-11dd-bde6-c5438ada3082}.

C:\bcdedit /set "{new_id}" device "vhd=[D:]\Virtual Machines\Native\Windows7.vhd"
The operation completed successfully.

C:\bcdedit /set "{new_id}" osdevice "vhd=[D:]\Virtual Machines\Native\Windows7.vhd"
The operation completed successfully.

C:\bcdedit /v
...
Windows Boot Loader
-------------------
identifier       {2fae45a9-f1ca-11dd-bde6-c5438ada3082}
device           vhd=[D:]\Virtual Machines\Native\Windows7.vhd,locate=custom:12000002
path             \Windows\system32\winload.exe
description      Windows 7 VHD
locale           en-US
inherit          {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
recoverysequence {2fae45a7-f1ca-11dd-bde6-c5438ada3082}
recoveryenabled  Yes
osdevice         vhd=[D:]\Virtual Machines\Native\Windows7.vhd,locate=custom:22000002
systemroot       \Windows
resumeobject     {2fae45a5-f1ca-11dd-bde6-c5438ada3082}
nx               OptIn

If you moved image from another system and you with to boot from it, you may also need to turn on HAL detection:

C:\bcdedit /set "{new_id}" detecthal on
The operation completed successfully.

At this point, there is nothing more to do. You may restart and boot into your favorite VHD.

[2009-05-17: Adjusted bcdedit commands so they work both in cmd.exe and in PowerShell]

Bluetooth on Windows Server 2008

Illustration

One of things that differs Windows Server 2008 from Windows Vista is lack of bluetooth. For some reason it was decided somewhere is Microsoft that bluetooth is not a feature for server operating system. While I may partly agree that on real server there is no need for bluetooth, one needs to remember that before anything gets installed on production servers, it needs to be tested. Usually that testing is done on any machine that is available. That often is just some old workstation or notebook. Those computers often do have bluetooth and, since testing can last for few months, sooner or later some bluetooth device comes up.

There is option of installing bluetooth stack from your bluetooth manufacturer. But, not only those stacks are little bit overkill for just connecting your mouse, most of devices these days lack the CD with stack altogether. Manufacturers got so accustomed on people having default stack installed that they do not bother even creating custom one. Even those that have stack available (Broadcom, Toshiba…), bury it deep inside of website.

Cheating

Another way to get a bluetooth stack is to use Vista drivers. Although for almost all other drivers there is complete compatibility of drivers (in sense that you can install Vista drivers on 2008 and have them working), bluetooth stack cannot be installed directly. Solution is to adapt procedure a little.

On Windows Vista (yes, we need Vista) go to “C:\Windows\System32\DriverStore\FileRepository” directory and start search for “*bth*” (notice star before bth). That will get you quite a few hits. Just copy everything that appears in one folder (do not keep folder structure) and has .inf, .sys or .exe extension (no need for .pnf files). That will give you quite a few files and with subdirectories’ files included (e.g. fsquirt.exe), you have all files. You do not need to worry about duplicate files. One copy of each file will do.

Now you need to edit all .inf files. Just open them all and change any appearance of “NTamd64…1” to “NTamd64…3” (two appearances per file). This tells windows that those files support both desktop and server operating system.

You can go into Windows Server 2008 now and when asked for bluetooth drivers, just give it a path to that directory where all work was done. Drivers will install as normally and you will have your bluetooth working.

Windows 7 Videos

Illustration

Here are some Windows 7 videos that I found useful and educating. They are all from Microsoft’s own Channel 9.

Mark Russinovich: Inside Windows 7

This one is a real gem. It is hard to pinpoint subject since they go all around Windows 7 topics, but if you are a developer or just guy who likes to know technical details - this is video to look. If you are searching for some more details on startup/shutdown workings, there is another video (from Chittur Subbaraman) for you also.

Windows 7 New Taskbar - An Overview

To get a grasp on how exactly new taskbar works, you may wish to see this. If you like this check other videos of same series. They additionally deal with its design, internals and jump lists.

A lap around Windows 7 new Scenic Ribbon

Introduction to ribbon interface. Nothing new for those who already worked with Office 2007. For more technical details, you may want to watch this also.

Larry Osterman: Windows 7 Audio - What’s New

Some changes in area where nobody seemed to have a problem. :)

Windows 7: Find and Organize Part 1 - The User Experience

This one is about new way of organizing things inside Windows 7 (libraries and such stuff). If you are developer, part 2 may interest you.

Microsoft Access X64

As many of you, I am a sinner. I have been using .mdb as database of my choice for small projects. I knew even then that there are better choices out there but .mdb was easy accessible over OLEDB, in need you could use Microsoft Access to edit database (yes, I did ugly “just this time” fixes on data), it didn’t kill machines with small amounts of RAM and its network model was sufficiently fast on local networks (although someone may argue whether it had any network model at all).

Story of one bug

As I sometimes do, I got bug report for one of old programs. Since I like to confirm things first, I opened project in Visual Studio 2008 (of course, conversion was needed since that was 2005’s project) and started it. There was a strange error: “The ‘Microsoft.Jet.OLEDB.4.0’ provider is not registered on the local machine.”. Of course, reading is not necessary for my level of experience so instead of analyzing what was said to me, I decided to install Visual Studio 2005 and run the program without conversion. Same error.

Google

My blind faith in google forced me to try bunch of stuff. One wise guy said that Vista comes without MDAC so I tried to install it. Other one said that you need to manually register MDAC files. I did that also. After installing all possible updates (did you know that Jet 4.0 is at SP8?) I decided to search Microsoft’s support. First page offered was one with my problem. There is no 64-bit version of Jet. OLEDB provider. At that minute I remembered that I do run 64-bit Windows…

Solution

Once I finally knew what exactly is problem here, solution was easy. We just need to go back to 32-bit world in order for things to work.

Illustration

Illustration

In C# that is done in Project Properties, Build page. Just select x86 as platform target and everything will start working as it was before. In case you have some dlls that access database, you will need to convert them also.

In case you are working in VB, path is little different since you need to go to My Project then Compile tab and on Advanced Compile Options button you will find target CPU setting.

After that small change, your program is 32-bit citizen and loading 32-bit OLEDB is easy as it once was.