Tag Archives: Windows 7

Kinect for Windows beta SDK Released

Download it now: http://research.microsoft.com/en-us/um/redmond/projects/kinectsdk/

Interested? Here’s some resources:

I got mine.  Do you?

What’s that Version?

Not sure why but in Windows 7 when you look at the properties of a .NET assembly and go to “Details” it shows you the “File version” and “Product version”.  Unfortunately, they are both the same and it’s confusing trying to figure out what version number it is really showing.

image

With Microsoft .NET assemblies, there is an assembly version and there is an assembly file version.  The assembly version is the version you think of when you want to know an application’s version number.  E.g., version “1.2.3.4” and I believe that it should be in the “Product version” in the details window but it’s not.  The assembly file version is used more to indicate which build created the assembly.  E.g., version “1.2.2234.332”.  Therefore, it is usually a more accurate version number and it’s the one that is displayed in the “Details” window (for both version numbers listed).

Now, back to Windows 7.  You can’t just look at the properties and get all of the version information that you need.  For this reason I created a utility to tell me the version info (assembly and assembly file versions) and the strong naming information as well.

Here’s what it looks like when you start it up:

image

If you drag an assembly from Windows Explorer into that window it will extract the name and version information and display it like below:

image

You can keep dragging files into the window as many times as you want.

Julian Date in the version:

I use “Julian” dates in my versioning so that the Assembly File Version can increment with each build.  If you look at the version above you will see that the third version value in the Assemby File Version is “11112”.  It’s nice that it’s a Julian date but what day is it?  Right click on the window and you will find out through a message box like this one:

image

Now you can see that it was April 22, 2011.

You can get the code for the Version Reporter here: http://bit.ly/e4Mu5L

Anyway, this is a useful utility for testing to see if your build versioning process is working and for verifying version numbers in assemblies as you are trying to deploy.

Preorder and Save on Visual Studio 2010 Upgrade

Microsoft Visual Studio 2010 Professional will launch on April 12 but you can beat the rush and secure your copy today by pre-ordering at the affordable estimated retail price of $549, a saving of $250.

If you use a previous version of Visual Studio or any other development tool then you are eligible for this upgrade. Along with all the great new features in Visual Studio 2010 (see www.microsoft.com/visualstudio) Visual Studio 2010 Professional includes a 12-month MSDN Essentials subscription which gives you access to core Microsoft platforms: Windows 7 Ultimate, Windows Server 2008 R2 Enterprise, and Microsoft SQL Server 2008 R2 Datacenter.

So visit http://www.microsoft.com/visualstudio/en-us/pre-order-visual-studio-2010 to check out all the new features and sign up for this great offer.

Windows 7 Power Configuration Diagnostics Report

I came across a Windows 7 utility (“PowerCfg.exe”) that does a scan of your system (actually watches for 60 seconds) and then generates an HTML report describing what it found as errors, warnings and general information.  I gave it a go just to see what it said and was surprised when I got spanked with a series of error level messages.  Of course I thought that it was just being nit-picky but then realized that it was telling me that I made some mods to the energy profiles but never changed them back.  I did the changes because of a presentation that I was part of and didn’t want my machine going dim or even worse going to sleep. 

The report categorizes the power policies as “On Battery” or “Plugged In” and some of my On Battery settings were definitely off.  I’m sure the day was coming where I would be running unplugged and the battery would have been draining fast as I went merrily on running the laptop at full bore.  The power plan was set to “High Performance”.  I had no timeouts on the display or when to put it to sleep.  The disk was set to run full speed whether I was using it or not. 

In addition, in the warning section, there was a list of applications that were sucking up the majority of the CPU.  Not surprising, a virtual PC session was grabbing a bunch but Internet Explorer was chewing up even more.  However, as the report displayed, it was the Flash component within the page that IE was displaying that took up more than 43% of the 47% CPU utilization that the POWERCFG utility was complaining about.  Hmmm – good to know.

Ultimately, this is a good utility to run every once in a while to review the current state of your machine and then take action to reduce settings and extend battery life.  But wait, that’s not all!  I had some settings that were changed for that same presentation that make my laptop suck up more energy than it needs when it’s plugged in.  With the ice caps melting, Polar bears losing their environment and the Ozone layer disintegrating, every little bit helps.  I don’t need my display on high or my disk drive spinning when I am away from the machine for a while.  Nor do I need it to remain powered up all night.  All this wastes a bunch of energy.

polar-bear1

Now, I know you’re saying to yourself…”I wanna become a more responsible citizen too. How do I do it?”.  Well, here it is:

  1. Open up a command window with elevated privileges.  In other words, right click on cmd.exe and select “Run as Administrator”
  2. Change the current directory to a location where you can write a file and then be able to read it.  The PowerCfg.exe utility is going to generate an html file.
  3. Type the following command: powercfg –energy –output energy-report.html

Run PowerCfg

Look at that would ya? 17 errors and 24 warnings.  Seems like a lot.  You can type “energy-report.html” at the command prompt and the report will pop up in your browser.  Most of my errors were due to the “maximum performance under all conditions” setting that I chose.

After going to my laptop’s power utility I set it to adapt to the cpu requirements rather than just go all out, also set it to power things down and go to sleep when I’m not using it.  Errors dropped to 4 and fewer warnings as well.  Much better.

And here’s the proof – look how much happier they are now.

070907214013_Polar_Bears_LG

Moral of the story is: review your performance settings every once in a while – the polar bears will thank you.

Create a Virtual Drive (VHD) in Windows 7 using PowerShell

Creating a virtual drive in Windows 7 is a fairly simple task but I wanted to create a PowerShell script that would make things just a bit easier to perform.  This script contains a function (“Create-VhdDrive”) that only requires 2 parameters (path and filename) to create the new VHD disk but it does allow you to override all of the possibilities so you can create a fixed verses expandable, set the size, identify the drive letter to mount the new drive to, etc.

This script creates a VHD file, formats it and mounts it to your system.  It does not attempt to set up the drive for “Boot to VHD”.

The script requires that you are an administrator and when it runs the “Are you sure you want to do this” dialog will appear.

As the script runs a dialog box may appear like the one below:

Need to Format

Cancel out of that window since the script does format the drive for you.

When the script is done, the auto-play dialog will appear. 

AutoPlay

In fact, it may appear before you have a chance to cancel out of the format dialog.  This may happen if you create an expandable drive since an expandable drive does not require setting aside all of the required space ahead of time.

Once that dialog appears, the drive has been created and is ready for use.

Here is the script (there is an example of a call to the main function (“Create-VhdDrive”) at the bottom of the script):

# CreateVhd.ps1
#
# Summary: This script will create and attach a Windows 7 Virtual Hard Drive (VHD)
# The Virtual Hard Drive is essentially a file that can be attached to a Windows 7
# machine in such a way that it appears and acts just as any other drive on your 
# computer.  Benefits include attaching and unattaching at will, being able to back
# up the drive simply by copying a single file, ability to create fixed or expandable 
# drives, ability to create any size drive up to multiple terabytes (assuming your 
# physical hard drive has the space), etc.

# function: Check-AvailableDrive
# This function will check to see if a drive letter is available. This is important
# when trying to assign and attach a drive.  The drive letter must not already be 
# in use.  
function Check-AvailableDrive {
    param ( $driveLetterToSearch )
    
    foreach( $driveFound in [System.IO.DriveInfo]::GetDrives()) {
        if ($driveLetterToSearch + ":`\" -eq $driveFound.Name) { return $false } # the drive letter is in use?
    }
    
    # Drive letter is available
    return $true
}

# function: Create-VhdDrive
# This function generates a script and passes that script to the DiskPart utility
# to generate a formatted VHD drive at a specified location.
# $vdiskPath (Required) is the drive:\folder location of the new VHD drive file
# $vdiskFileName (required) is the name of the new VHD file to create (Note: the file does not have to 
#   end with ".vhd" for it to work but it is the standard.
# The rest of the parameters are optional and have default values
function Create-VhdDrive {
    param ( $vdiskPath = $(Throw "vdiskPath was not specified"), 
            $vdiskFileName = $(Throw "vdiskFileName was not specified"), 
            $vdiskMaximumSize = 20000, $vdiskType = "EXPANDABLE", 
            $vdiskDriveLetter = "", $vdiskVolumeName = "NewVHD", 
            $vdiskScriptFileName = "CreateVhd.scr" )
    
    # Validate the drive letter
    if ($vdiskDriveLetter.length -eq 0)
    {
        $driveAssign = ""
    } else {
        if ($vdiskDriveLetter.length -ne 1) {
            Throw "Error: the variable `"driveLetter`" must be a single letter only."
        } else {
            if ((Check-AvailableDrive $vdiskDriveLetter) -eq $false) { 
                $errorResult = "Cannot create drive $vdiskDriveLetter - it already exists."
                Throw $errorResult 
            }
            
            $driveAssign = "LETTER=$vdiskDriveLetter"
        }
    }
    
    # Validate the disk type to be FIXED or EXPANDABLE
    if (($vdiskType -ne "FIXED") -and ($vdiskType -ne "EXPANDABLE")) {
        Throw "Error: vdiskType must be `"FIXED`" or `"EXPANDABLE`""
    }

    # Validate that the destination path for the new file does indeed exists
    if (![System.IO.Directory]::Exists($vdiskPath)) {
        Throw "Error: the destination folder does not exist - $vdiskPath"
    }
    
    # Create the full path for the new file
    $vdiskFullFilePath = [System.IO.Path]::Combine($vdiskPath, $vdiskFileName)
    
    # Generate the text for the script
    $scriptLineToWrite = "CREATE VDISK FILE=`"$vdiskFullFilePath`" MAXIMUM=$vdiskMaximumSize TYPE=$vdiskType`n"
    $scriptLineToWrite = $scriptLineToWrite + "SELECT VDISK FILE=`"$vdiskFullFilePath`"`n"
    $scriptLineToWrite = $scriptLineToWrite + "ATTACH VDISK`n"
    $scriptLineToWrite = $scriptLineToWrite + "CREATE PARTITION PRIMARY`n"
    $scriptLineToWrite = $scriptLineToWrite + "ASSIGN $driveAssign`n"
    $scriptLineToWrite = $scriptLineToWrite + "FORMAT QUICK LABEL=$vdiskVolumeName"
    
    # Write the script out to disk so it can be passed into DiskPart
    $scriptPath = [System.IO.Path]::Combine($vdiskPath, $vdiskScriptFileName)
    $scriptLineToWrite | out-file -encoding ASCII $scriptPath
    
    # Create the VHD Disk File
    diskpart /s $scriptPath
}

# Example function call to create a 30GB expandable file:
Create-VhdDrive -vdiskPath "d:\bootfromvhd" -vdiskFileName "MyNewVhdDisk2.vhd" -vdiskMaximumSize "10000" -vdiskVolumeName "MyVhdDrive01"

Boot from VHD Simplified

Ever since I heard that Windows 7 was going to support “Boot from VHD” I wanted to give it a try.  With promises like:

  • The flexibility of Virtual PC in that the drive is a file so backup and moving it around is greatly simplified
  • Speed increase because the OS is “Running on the Tin”
  • Flexibility of existing multiple boot but without requiring any special partitioning of the machine’s drives
  • Ability to use “most” of the existing hardware including USB

In my case, I wanted to work through all of the requirements and potential issues around installing the full Team Foundation Server 2010 environment.  Using the VHD approach, I could use almost all of the potential speed of my machine but as I was working through each step of the installation, I could stop and backup the vhd file at each step of “success”.  This way, if any less than successful results happened after the last backup, I could restore the last good version simply by copying a file.  I took major advantage of this ability as I attempted various install options.

Anyway, it all sounded great and in addition to the above, I have additional reasons for needing the capability.  I don’t want to have to carry multiple machines with me on the job and I don’t want to have to put up with the performance degradation or using all of my machines resources to run multiple OS’s in a Virtual PC approach.  I started doing research around how to get things properly in place to make it happen and I was initially confused with the multiple ways to potentially make things happen.  You can create the image while booting from a DVD, run a combination of commands from DiskPart and BCDEdit and ImageX and so forth.  Personally, I wanted something simple and reliable – something that closely mimicked what I would normally do on a fresh machine.  The following is just one way to make “Boot from VHD” happen but it works and is pretty simple to do.

System Requirements:

  • Host machine needs to be Windows 7 (Enterprise or Ultimate)
  • The new VHD OS must be Windows 7 (Enterprise or Ultimate) or Windows Server 2008 R2

Note: I’ve read about some potential tricks to fool the system into allowing OS’s other than Win7 and W2K8 R2 but I haven’t tried them nor are they a supported option.

I started with a 64 bit dual-proc laptop.  I do a LOT of work with Team Foundation Server and as I stated above, I wanted to load the new beta bits.  TFS needs to be loaded on a server so Windows Server 2008 R2 was the logical option for the new VHD operating system (luckily, I am working with a 64 bit laptop since R2 is only 64 bit).

The following are the major steps I went through to make this happen:

  1. Started with my laptop running Windows 7
  2. Created a Windows Server 2008 R2 boot DVD
  3. Booted the machine with the R2 Server DVD
  4. Create the virtual hard drive and attach it through a CMD window and the Diskpart utility
  5. Continue to use the standard installation process via the DVD
  6. Select the appropriate disk to load the W2K8 R2 OS
  7. Continue installing as normal
  8. Reboot into Win7 OS
  9. Set boot priorities and descriptions using BCDEdit and MSConfig

Here are the steps in detail:

1.  Boot a Windows 7 machine using a DVD.  I used Windows Server 2008 R2 (W2K8 R2)

BootR2DVD

2.  When the initial installation window appears to install W2K8 R2, press SHIFT-F10 to bring up a command (CMD) window.  In the command window, execute the “diskpart” utility application.  Through this utility we can create a virtual hard drive (VHD) file and attach it to the current OS so the installation can see it.  Below are the commands to run within DiskPart:

CREATE VDISK FILE=”insert the full path file name here” MAXIMUM=##### TYPE=[FIXED | EXPANDABLE]

In my case, I put the VHD in a folder on my D: drive, set the maximum size to 64000 (64 GB) and made it expandable.  I am willing to take the risk and performance reduction in return for not taking up the full 64 GB on my disk right away.

Note: the VHD file should not exist before this command is issued but if a sub-folder is to be used, that sub-folder must exist.  The “MAXIMUM” parameter identifies how large the virtual disk is to be.  This size number is in megabytes.  The TYPE parameter indicates whether the disk is to be created at its full size or if it is to grow over time up to its full size.  FIXED will provide higher performance but requires the full size allocation to be created from the start.  EXPANDABLE is somewhat less performant but does not require the full space allocation – it will grow over time.  One potential issue is that if the physical disk becomes full and the expandable VHD attempts to grow, there will be a write error and the results are unpredictable.

SELECT VDISK FILE=”same path as above”

ATTACH VDISK

CREATE PARTITION PRIMARY

ASSIGN

FORMAT QUICK LABEL=YourVolLabel

EXIT

Note: These steps will create the VHD file, attach the “disk” to the system, create the primary partition, assign a drive letter and format the new drive.  It will now be available to the W2K8 R2 installation process.

diskpart

3.  Exit out of the CMD window

4.  Continue on with the installation.

BootR2DVD 

5.  Select the “flavor” of OS to install.

 R2Selection

6.  Select “Custom” rather than “Upgrade”.  This will install the full “new” operating system to the partition.

CustomSelection

7.  A few screens later you will be able to select the partition to install the new operating system into.  You will be able to identify the appropriate partition by a couple indicators.  It should be the last partition in the list.  It will contain the volume label that you used in the “diskpart” commands (I used “W2K8R2Tst” as shown below).  Finally, the size of the partition could be an additional indicator.  Select the new partition and click “Next”.

PartitionSelect

8.  After that, continue with the install as normal.

FinishInstall

 

9.  The last thing to do is just some cleanup.  When the install is complete, reboot the machine into the original Win7 OS.  Even though you log in under your ID, it may boot up using an alternative profile and your desktop may not look as it should.  If this is the case, do the following:

  1. Click on the start marble
  2. Enter “msconfig”
  3. Select the boot tab
  4. Select the Windows 7 “Current OS” line.  It should be the last line.
  5. Click “Set as default”
  6. Click “OK”

msconfig

This will do a couple things.  It will set your machine’s Win7 OS as the default so when the multiple boot screen comes up, it will automatically select Win7.  It also seems to get rid of the alternate profile issue so when you reboot, your regular desktop will appear.

10.  This step is completely optional but if you want to define your own description to the boot selection rather than the default then using BCDEdit gives you the ability to change the default descriptions.  This helps when you have more than one possible boot VHD’s that use the same OS.  Instead of having to guess which “Windows Server 2008 R2” to boot up with, you can be sure with different descriptions.

  1. Open a Command window with elevated privileges.
    1. Click on the Start Marble
    2. Type “CMD”
    3. Right-click “cmd.exe” in the resulting list
    4. Select “Run as Administrator”
    5. The command window should appear
  2. Type “BCDEDIT”.  This will display the boot list.
    1. Look for the newly created boot record.  It can be identified by reviewing the value next to the “device” parameter.
    2. Directly above “device” is the “identifier” GUID that you need to use in the BCDEdit command syntax
    3. Copy the GUID including the curly brackets
  3. Type: BCDEDIT /set {YOUR GUID} description “YOUR NEW DESCRIPTION”
  4. Hit Enter

This will change the description as shown below:

bcdeditReview

ChangeDesctiption

DescriptionChanged

As you can see, the descriptions are now changed.  These are the values that you will see when the machine initially boots up and the multiple boot options appear.  By the way, MSConfig also allows you to delete the boot option from your machine by selecting the one that you want to delete and then clicking the “Delete” button just below the boot list.

That’s it.  You should be about to follow these steps to install a Windows Server 2008 R2 or additional Windows 7 VHD giving you multiple boot capabilities.