Archive for the ‘Windows 7’ Category.

Install Telnet.exe from the command line

I have a previous post about installing telnet.exe in windows 7, however, I explain how to do it using the UI. You may need to install telnet.exe from the command line.

To install telnet.exe on Windows 7 from the command line, run this command:

C:\Windows\system32>dism.exe /online /Enable-Feature:TelnetClient

Now telnet to a machine:

c:\> telnet 10.1.1.1

Yes, it is that easy. Of course, you may think about using ssh these days as telnet just isn’t that secure. However, telnet is used for other things, such as port testing.

You can telnet using a different port or test that a port is open just by adding the port number.

c:\> telnet 10.1.1.1 3389

Smart phones and tablets can’t replace a desktop or laptop, yet!

I completely believe that the phones and tablets like the new T-Mobile 7″ Samsung tab are going to be continue to be huge industries and will not go away as the Palm Pilot did. However, will they continue to explode exponentially as many believe? Or is there a plateau coming?

I just reviewed the Motorola Xoom and it was a great tech toy. However, it wasn’t much more than a casual gaming tool. There is a crucial flaw that has yet to be solved with phones and tablets: Typing.

No matter how fast you can type on a phone or tablet, you will never type as fast as you can on a keyboard. Might there be a solution better than a keyboard that we just haven’t discovered yet…maybe…but even if we discover it will it work on a phone or tablet?

There are certain uses for a phone:

  1. Making calls
  2. MP3 player
  3. Texting
  4. Casual gaming
  5. Visual browsing (such as checking the whether)
  6. Reading email (notice, I didn’t put writing email)
  7. Pocket Portability
  8. GPS and Navigation
  9. Quick low quality photos/video

There are certain uses for a tablet

  1. Book reader
  2. MP3 player
  3. Casual gaming
  4. Visual browsing (such as checking the weather)
  5. Reading email (notice, I didn’t put writing email)
  6. GPS and Navigation
  7. Quick low quality photos/videos

However, will the Laptop and Desktop be taken over by a tablet?  What about 20″ to 27″ monitors? Some of use need so much real-estate we have multiple monitors.  Here are using for a computer that a tablet does not solve.  For those of you thinking of going 100% to phones and tablets, you may just want to hold on.

Here is a list of requirements and uses that are met by a desktop or laptop that the phone and tablet haven’t really solved yet.

Note: I am not going to repeat the items on the list for the smart phones and tables but be aware that the only feature the phone or tablet has that a desktop or laptop doesn’t have today is pocket portability.

  1. Keyboard and typing
    1. Writing email
    2. Writing documents
    3. Creating spreadsheets
    4. Writing code, yes, even writing code for tablets
    5. Writing blog posts (like this one)
  2. CD/DVD/Blu-Ray drive (yes, people are going to still want to play there DVDs and Blu-Ray movies 10 years from now)
  3. Monitors
    1. 17″ or larger monitor
    2. Multiple monitors
    3. Viewing multiple applications simultaneously
  4. Local storage of data.
  5. Serious desktop gaming
    1. Joysticks
    2. Short-cut keys
  6. Peripherals
    1. Printers
    2. External drives
    3. Cameras and Video cameras
    4. Projectors
    5. Custom peripherals (like those that are designed for one company, telescope, craft vinyl cutters, industrial equipment, etc…)
  7. Ethernet, no not everywhere has wireless yet and some secure facilities will never have wireless or allow VPN from a 3G/4G device. Some places don’t allow web-cams or camera devices and unfortunately you can’t take your camera out of your phone or tablet.

We have been using desktops for three decades. Smart-phones and tablets are in their infancy. Many problems, including millions of custom problems for companies in all industries, have been solved using laptops and desktops. To replace desktops and laptops, these problems will have to be solved.

Many problems have solutions already.For example, blue-tooth and wireless technology can allow for peripherals but there are a lot of devices already out there that are not blue-tooth or wireless capable.

But another road block is in the way. Adoption.

Adoptions takes a long time.  First the manufacturers have to adopt a technology, design new products, produce them, distribute them.  Then consumers have to buy the new technology and if they already own an older version, that older version often has to go through its life cycle which can take a lot of years. I still have an HP LaserJet 5L from the late 90s that works perfectly. No, I am not going to invest in another laser printer until this one dies.

So will someone still be running a desktop or laptop with Windows XP/Vista/7 in 2020. Certainly.  Will they probably own a smart phone or tablet as well.  You bet!

Adding this post from Internet Explorer 9 to write about Internet Explorer 9

If you are using Windows and you are using Internet Explorer 9, you are becoming a minority.

W3Schools has a browser statistics site that basically is made by tracking the browsers that hit it.

http://www.w3schools.com/browsers/browsers_stats.asp

It is probably not exactly accurate because most poeple who go to W3Schools are probably in some way technical and doing some type of development, most likely for the web.  If there was a statistic built from the browsers that accessed the most popular pages on the web: Bing.com, MSN.com, Google.com, Yahoo.com, Youtube.com, Facebook.com, etc… then that would be accurate. But we make do with what we have.

This page shows that IE has a little over 1/4 the market share to start 2011, while it held over 1/3 the market share at the first of 2010.

2011 Internet Explorer Firefox Chrome Safari Opera
February 26.5 % 42.4% 24.1% 4.1% 2.5%
January 26.6 % 42.8% 23.8% 4.0% 2.5%
2010 Internet Explorer Firefox Chrome Safari Opera
December 27.5 % 43.5% 22.4% 3.8% 2.2%
November 28.6 % 44.0% 20.5% 4.0% 2.3%
October 29.7 % 44.1% 19.2% 3.9% 2.2%
September 31.1 % 45.1% 17.3% 3.7% 2.2%
August 30.7 % 45.8% 17.0% 3.5% 2.3%
July 30.4 % 46.4% 16.7% 3.4% 2.3%
June 31.0 % 46.6% 15.9% 3.6% 2.1%
May 32.2 % 46.9% 14.5% 3.5% 2.2%
April 33.4 % 46.4% 13.6% 3.7% 2.2%
March 34.9 % 46.2% 12.3% 3.7% 2.2%
February 35.3 % 46.5% 11.6% 3.8% 2.1%
January 36.2 % 46.3% 10.8% 3.7% 2.2%

So why am I telling you this, in my review of Internet Explorer 9?

Because I am telling you to get ready for the percent of IE users to rise again with the release of IE9.

So far, I have the following positive feedback.

  • Feature that weren’t working before, such as rounded corners on the red borders of the boxes on my blog, are working.
  • The browser opened with amazing speed. Yes, I didn’t just say speed, I said AMAZING SPEED.
  • The About:Tabs page that opens by default in a new tab is quite awesome and is pretty close to a replacement for the Speed dial
  • The cleanthiness of the browser is refreshing.

The negative feedback I have so far is simply one:

  • I tried to find a plugin but found the plugin page hard to find and I could not find a way to search for IE9 plugins.

Right now I dual boot between FreeBSD and Windows 7.  When I am booted to FreeBSD, I will use Firefox. Normally in Windows 7 I also use Firefox.  Right now, I am not going to install Firefox in my new Windows 7 install in my dual boot scenario unless I start to dislike IE9.

Dual-booting Windows 7 and PC-BSD

Hey all,

I was going to write an article on this, but it was so easy, there is no need for one.

Windows 7 doesn’t know how to deal with PC-BSD, but PC-BSD knows how to deal with Windows 7.

So all I had to do was install Windows 7 first (I chose a 50 GB partition) and then I installed PC-BSD on the remaining space. I did click to install the PC-BSD boot manager as it is not selected by default, and now I can dual boot Windows 7 and PC-BSD.  Which is a must for a guy who’s job is writing C# on windows.

New Laptop Hard Drive!

I just got a new 250 GB 7200 RPM laptop hard drive for $45 bucks from NewEgg.

I plan on installing Windows 7 SP1, FreeBSD 8.2, and PC-BSD 8.2.

You know what would be interesting is to link /usr/home on FreeBSD 8.2 and the PC-BSD 8.2 OSs so that my /usr/home/jared is the same directory on both.

Article: Speed Up Windows by Stripping It Down

I found this article on stripping down Windows.  I have wanted to remove unnecessary services from Windows 7 for a while.  I want to save it for later.

I explains how to remove unnecessary prettiness and services that take a lot of CPU power.

Speed Up Windows by Stripping It Down

Twelve windows applications Microsoft should make open source on their CodePlex site

Microsoft is a big company and has a lot of developers, and it wouldn’t seem they need help from the community. However, the have a lot of code and a lot of different projects that keep the developers plenty busy. At least they are too busy to provide some simple features that exist in almost every other operating system.

There are obvious shortcomings in many of the included Microsoft applications.  Open source communities are excellent at rounded out an application.

If Microsoft were to open source some of their software, and allow for at least for read access on whatever source control they use, then allow for not only submitting bugs but submitting patches, that can be reviewed and applied or rejected, then they could see a wave of improvements come from the many different windows users: Enterprise admins, developers, power users, etc.

It is also nice to be able to debug an application for Microsoft.  It is not always easy to duplicate bugs in house, so if a developer experiences an issue that is annoying enough, they would fix it themselves and while yes, Microsoft benefits, more importantly, all the other users of that application benefit.

http://www.CodePlex.com

Microsoft started ww.CodePlex.com, and it is very similar to SourceForge.net.  They have just under five thousand projects that claim to have stable releases.

Why doesn’t Microsoft make more of their own projects available on CodePlex?

Microsoft could have many open source projects that could become large communities.  One open source community that continues to gain popularity is Windows Install XML. It seems to be a large community now and is growing rapidly.  Strangely it is actually hosted at Sourceforge.net, though it has some sort of presence on CodePlex.

How many Open Source project could Microsoft have?

More people develop using Windows than any other operating system.  (Yes, phone OSes may have or may someday take that over…but that is besides the point).  Think of all the software companies in the world. How many of them don’t develop for Windows.  Even Apple spends a lot of time making iTunes work on Windows.  There are so many developers that might contribute that it is impossible to count them all. Some may end up contributing as part of their job. Many developers might contirubte to a project because it makes their development lives easier. Many enterprise customers might contribute to lower the costs of managing their environment. Many consulting and contract companies might contribute for their own reasons.

So what applications should Microsoft start with?

Here are a list of applications that Microsoft should open source immediately.

#1 – Notepad.exe

Yes, this is the most simple editor that we never use. One of the first thing my colleagues and I do whenever we install windows, is install Notepad++.  While we love Notepad++, we don’t love that we have to install all the time.

After more than 15 years since Windows 95 (or is it more, was notepad.exe in Windows 3.11?) notepad.exe should be one of the most functional and efficient editors in the industry.  However, notepad lacks features that are critical to a good text editor. The most important being syntax coloring. Others features such as supporting regular expressions in find and replace, supporting plugins (especially the XML plugin), are features we use in Notepad++ often. There is really no excuse for Microsoft not having these features. The community has provided these feature for you, all you have to do is include them in your base system.

There are actually many different Notepad-like projects on CodePlex. Maybe some as as mature as Notepad++ maybe some arent. The question is whether any of them will ever become a standard part of the base windows install?

Maybe Microsoft keeps notepad.exe simple, but adds a second more advanced application like Notepad++ in the base system. Or why not just include Notepad++, it is free, after all.

#2 – Internet Explorer

Ok, so Mozilla Firefox and Google Chrome are open source. Microsoft is losing ground to both browsers and this is not going to change in the near future.

Brand is important, however, is really anything left to gain by winning the browser war. Maybe using IE to kill Netscape in the late 90s was important back then. But would anyone really care if IE went away and windows shipped with your choice of the other browsers available? We don’t think so. This is actually how Europe installs of Windows are today. The homepage and search engine war is what is important and Microsoft could still control that on its operating system by having the homepage be msn.com and the default search engine be Bing.

So what use is it for Microsoft to spend time and money developing IE? None really.  It is a waste of time and money they could spend elsewhere.  Release this software to the community. Besides, the new IE development community would not be hampered by being part of an organization that is too large to care enough about IE to release in a timely manner anyway.

If IE became open source, it would be rejuvenated in a way Microsoft can’t do in any other way.

For example, This blog’s home page has a boxes with rounded corners. IE is the only browser that doesn’t support the rounded corners feature in CSS. This feature would have been implements years ago were IE Open Source, as many other features would have as well.

#3 – Windows Explorer

If there is anything that needs debugging help from the community, it is Windows Explorer. Like Notepad.exe, Explorer.exe just hasn’t evolved the way an application should. Even on Windows 7 we all have experienced issues including constant unreproducible hangs, crashes, and failure to refresh.Whether these are due to explorer or something that is plugged into explorer, the inability for a user to do anything about it annoying, especially if that use, like me, is a developer and may or may not have the ability to debug and fix the issue.

Also like Notepad.exe, there is a lack of features and plugins.  After almost two decades of existence, Explore.exe should be one of the most feature rich file browsers in the industry.  But instead, Explorer is difficult to work with if you want to do anything other than just work with the file system. One example of this: TortoiseSVN/TortoiseCVS cannot install and plugin to Explorer without prompting for a reboot. If released as a community project, Explorer.exe would become on of the most feature rich tools in windows.

#4 – Windows Live Messenger

So Windows Live Messenger hasn’t worked for me in months. Microsoft updated it with Windows Update.  Guess what.  It hasn’t worked since. And this is true for a lot of people. Many in my office have seen this as well as many others who are posting to their support site. See my previous article: Windows Live Messenger update broke again: Error 8100030d. This isn’t my only complaint, though the fact that they are releasing a product that doesn’t work is quite tainting to the Windows name.

I kindly offered to debug this issue for them, but my post to their support bulletin was ignored.

Even more annoying than the fact that Windows Live Messenger isn’t working for many people missing feature is the conceited attitude that users of Windows Live Messenger don’t also use other messaging tools. Most messenger applications now support logging into AIM, MSN, Yahoo Messenger, and many others.  But not Windows Live Messenger. If released as an open source project, the Windows Live Messenger community wouldn’t let this missing feature remain absent from the project.

#5 – MSPaint

MSPaint finally had its first bump in features with Windows 7.  However, it is still a shell of what it could be. What could it be? It could be Paint.NET and users love Paint.NET. Paint.NET is everything that MSPaint should be but isn’t. Paint.exe should be a well developed, feature rich application by now. However, Microsoft doesn’t spend any time on it.

So why not put the Paint.net project out there for the community. I don’t quite install Paint.NET as often as Notepad++, but I use it and install it quite often. Why do we have to go out and download and install Paint.NET.  Why after more than a decade and a half can MSPaint be such a basic featureless application.  Because there is no plan for it. Nobody is assigned to create a project plan and drive improvement for it. Even a one person project would be more developed than this after a decade and a half. If there hadn’t been a push to make it more Vista/Windows 7 like, it wouldn’t have gotten the recent update it received.

Look at the successful projects that exist: Paint.NET, Gimp, Pinta, and others. If Microsoft had sponsored such a project years ago or when MSPaint first came to existence, it might be rivaling Adobe Photoshop by now.

#6 – Hyperterminal / Telnet / FTP, etc…

Microsoft doesn’t have an SSH tool of an SFTP tool by default. Are you as frustrated as I am when downloading PuTTY and WinSCP for the hundredth time. Almost every open source operating system has these features as part of their base operating system. Yet Microsoft has somehow found a way to not include them.

An ssh/sftp tool set, both a command line and gui version, should be an open source project on CodePlex. Sure, leave them off of Windows Home Edition and make them have to be installed late. But these features should be included in a standard installation of Windows Ultimate.

#7 – Windows Command Prompt / PowerShell

The PowerShell is a little late to the game. Look at all the shell scripting abilities in open source operating system with sh, csh, ksk, bash, tcsh, etc…  Even OS X can use these.  Microsoft is so far behind when it comes to shell scripting. Let the shell be managed by the community.  Or replace it with a shell, or include a shell.

We can of course install Cygwin but again, why should we have to?

#8 – Hashing tools

On any other platform, we can easily download a file, and check the md5, sha1, or sha256 hash on that file. This is important because when you download software, especially from sites such as SourceForge.net, they always include a list of hashes you can use to make sure that the file was downloaded correctly and that it wasn’t tampered with.

Open a command prompt in windows and type md5, sha1, or sha256 and you will be told that such files are not found.

#9 – .NET Framework

Microsoft is trying to port .NET Framework and one source at Novell SUSE informed me that Microsoft was paying them to deliver open source versions of Silverlight (Moonlight) and .NET Framework (Mono) for open source platforms.  If they open sourced .NET Framework, porting it over would be much more simple and the project might have more community developers.

The ability for software vendors who have so many .NET applications already developed to be able to port them to run on MAC and Linux is going to drive this technology into the forefront over the next decade.

The entire .NET Framework library doesn’t have to be released, but if it was, it would be beneficial to more than just developers for Mono. Developers for Windows would also like to know how something is done in code, and Microsoft has thousands of examples, they just aren’t sharing them.

#10 – Windows Media Player

We want one Media app to rule them all. Windows users are tired of having multiple media players installed. Nobody wants to have all the following apps on their box: WMP, QuickTime, RealPlayer, MPlayer, FlashPlayer, and other one off players.

We are all tired of not being able to play a specific file or media type. If the WMP project were open sourced, it could become the one and only player a user would ever need, with the ability to play media types other codexes that it cannot play now.

Someone would surely write code for it to manage the music on iPods and other MP3 players in a quality manner. This is also strategic for the brand and tactical business act in that this would essentially kill iTunes, and lead the music buying industry back to whatever site Windows Media Player delivered, probably something that gives Microsoft a percentage of the purchase price.

#11 – An Application update service for all applications

Every single application thinks it needs to write its own software to update itself.  And they all have to run their own icon in my task bar, and check for their own software. There should be a project started called the application update services and applications register with this service.  Then one single icon in the task bar can look up the update needs for any application on the system.  No more separate updates from Java, Adobe, and others.

#12 – Regedit.exe

Many of you who are like me are in the registry all the time, developing it, testing it, troubleshooting it, checking settings, changing settings, tweaking performance.  There are dozens of simple features that Regedit.exe is lacking.  Such as the ability to past in a long registry key and have the tool browse to that key, like Explorer.exe allows for directories.  No, you have to click on every last key yourself.

Not to mention that there could be dozens of plugins that allow for making all the things we do in the registry easier (remember the earlier list: developing it, testing it, troubleshooting it, checking settings, changing settings, tweaking performance).

Why is each root key on the same screen, maybe they should be separate tabs?  If this were open source, someone could create that option.

Why can’t we go to an Ethernet tab and have a some easy options to optimize for 100 M or 1GB or the dozens of other advanced but common settings for Ethernet controllers, such as MTU.

Why can’t we do any of this?  Because the Microsoft developers are not being told to develop these in their road maps. But system administrators and desktop administrators and power users who live in the Windows world would love such features and many would add them if they only could have access to the source to do so.

Conclusion

Microsoft is starting to come around to the benefits of open source. They are much more open to it than they have been in the past and they can get the vision of open sources projects that they don’t need to maintain, then everyone will benefit in their own way.

How to read the 64 bit registry from a 32 bit application or vice versa

I found out that I needed to read the 64 bit registry from a 32 bit app today.

Why you might ask?

Well, I need to get the RegisteredOrganization value from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion and unfortunately Microsoft has a bug where the WOW6432 version of this key always says Microsoft, so a 32 bit application would always return Microsoft as the RegisteredOrganization, regardless of what the user entered when they installed the OS. This is hardly desired.

Note: This is also why all Visual Studio projects created in Windows 7 64 bit have Microsoft in the project’s Assembly Information. Change the WOW6432 version of the RegisteredOrganization and you fix this Visual Studio issue.
Well, turns out C# doesn’t have functionality until .NET 4, so prior to .NET 4, to choose the 64 bit hive when running a 32 bit app, so we have to do use a DLLImport and use RegOpenKeyEx, RegCloseKey, and RegQueryValueEx.

I don’t have this well commented, and it is not very newbie proof, but here are three different ways to do this. Hopefully you can understand one or more of these.

Example 1 – .NET 4 Example

Here is how to do this in .NET 4.

using Microsoft.Win32;

namespace Read64bitRegistryFrom32bitApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string value64 = string.Empty;
            string value32 = string.Empty;

            RegistryKey localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
            localKey = localKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
            if (localKey != null)
            {
                value64 = localKey.GetValue("RegisteredOrganization").ToString();
            }
            RegistryKey localKey32 = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
            localKey32 = localKey32.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
            if (localKey32 != null)
            {
                value32 = localKey32.GetValue("RegisteredOrganization").ToString();
            }
        }
    }
}

.NET 3.5 SP1 and Prior

This can also be done in .NET 3.5 and prior but it is not easy.
We have to do use a DLLImport and use RegOpenKeyEx, RegCloseKey, and RegQueryValueEx. Here are some examples.

Example 1 – A console application to read the 64 bit registry from a 32 bit application or vice versa

Here is the code in a simple one file project:
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace Read64bitRegistryFrom32bitApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string value64 = GetRegKey64(RegHive.HKEY_LOCAL_MACHINE, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization");
            Console.WriteLine(value64);
            string value32 = GetRegKey32(RegHive.HKEY_LOCAL_MACHINE, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization");
            Console.WriteLine(value32);
        }

        public enum RegSAM
        {
            QueryValue = 0x0001,
            SetValue = 0x0002,
            CreateSubKey = 0x0004,
            EnumerateSubKeys = 0x0008,
            Notify = 0x0010,
            CreateLink = 0x0020,
            WOW64_32Key = 0x0200,
            WOW64_64Key = 0x0100,
            WOW64_Res = 0x0300,
            Read = 0x00020019,
            Write = 0x00020006,
            Execute = 0x00020019,
            AllAccess = 0x000f003f
        }

        public static UIntPtr HKEY_LOCAL_MACHINE = new UIntPtr(0x80000002u);
        public static UIntPtr HKEY_CURRENT_USER = new UIntPtr(0x80000001u);

        #region Member Variables
        #region Read 64bit Reg from 32bit app
        [DllImport("Advapi32.dll")]
        static extern uint RegOpenKeyEx(
            UIntPtr hKey,
            string lpSubKey,
            uint ulOptions,
            int samDesired,
            out int phkResult);

        [DllImport("Advapi32.dll")]
        static extern uint RegCloseKey(int hKey);

        [DllImport("advapi32.dll", EntryPoint = "RegQueryValueEx")]
        public static extern int RegQueryValueEx(
            int hKey, string lpValueName,
            int lpReserved,
            ref uint lpType,
            System.Text.StringBuilder lpData,
            ref uint lpcbData);
        #endregion
        #endregion

        #region Functions
        static public string GetRegKey64(UIntPtr inHive, String inKeyName, String inPropertyName)
        {
            return GetRegKey64(inHive, inKeyName, RegSAM.WOW64_64Key, inPropertyName);
        }

        static public string GetRegKey32(UIntPtr inHive, String inKeyName, String inPropertyName)
        {
            return GetRegKey64(inHive, inKeyName, RegSAM.WOW64_32Key, inPropertyName);
        }

        static public string GetRegKey64(UIntPtr inHive, String inKeyName, RegSAM in32or64key, String inPropertyName)
        {
            //UIntPtr HKEY_LOCAL_MACHINE = (UIntPtr)0x80000002;
            int hkey = 0;

            try
            {
                uint lResult = RegOpenKeyEx(RegHive.HKEY_LOCAL_MACHINE, inKeyName, 0, (int)RegSAM.QueryValue | (int)in32or64key, out hkey);
                if (0 != lResult) return null;
                uint lpType = 0;
                uint lpcbData = 1024;
                StringBuilder AgeBuffer = new StringBuilder(1024);
                RegQueryValueEx(hkey, inPropertyName, 0, ref lpType, AgeBuffer, ref lpcbData);
                string Age = AgeBuffer.ToString();
                return Age;
            }
            finally
            {
                if (0 != hkey) RegCloseKey(hkey);
            }
        }
        #endregion
    }
}

Example 2 – A static class to read the 64 bit registry from a 32 bit application or vice versa

Or if you want this in its own separate class, here is a static class you can add to your project.
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace Read64bitRegistryFrom32bitApp
{
    public enum RegSAM
    {
        QueryValue = 0x0001,
        SetValue = 0x0002,
        CreateSubKey = 0x0004,
        EnumerateSubKeys = 0x0008,
        Notify = 0x0010,
        CreateLink = 0x0020,
        WOW64_32Key = 0x0200,
        WOW64_64Key = 0x0100,
        WOW64_Res = 0x0300,
        Read = 0x00020019,
        Write = 0x00020006,
        Execute = 0x00020019,
        AllAccess = 0x000f003f
    }

    public static class RegHive
    {
        public static UIntPtr HKEY_LOCAL_MACHINE = new UIntPtr(0x80000002u);
        public static UIntPtr HKEY_CURRENT_USER = new UIntPtr(0x80000001u);
    }

    public static class RegistryWOW6432
    {
        #region Member Variables
        #region Read 64bit Reg from 32bit app
        [DllImport("Advapi32.dll")]
        static extern uint RegOpenKeyEx(
            UIntPtr hKey,
            string lpSubKey,
            uint ulOptions,
            int samDesired,
            out int phkResult);

        [DllImport("Advapi32.dll")]
        static extern uint RegCloseKey(int hKey);

        [DllImport("advapi32.dll", EntryPoint = "RegQueryValueEx")]
        public static extern int RegQueryValueEx(
            int hKey, string lpValueName,
            int lpReserved,
            ref uint lpType,
            System.Text.StringBuilder lpData,
            ref uint lpcbData);
        #endregion
        #endregion

        #region Functions
        static public string GetRegKey64(UIntPtr inHive, String inKeyName, String inPropertyName)
        {
            return GetRegKey64(inHive, inKeyName, RegSAM.WOW64_64Key, inPropertyName);
        }

        static public string GetRegKey32(UIntPtr inHive, String inKeyName, String inPropertyName)
        {
            return GetRegKey64(inHive, inKeyName, RegSAM.WOW64_32Key, inPropertyName);
        }

        static public string GetRegKey64(UIntPtr inHive, String inKeyName, RegSAM in32or64key, String inPropertyName)
        {
            //UIntPtr HKEY_LOCAL_MACHINE = (UIntPtr)0x80000002;
            int hkey = 0;

            try
            {
                uint lResult = RegOpenKeyEx(RegHive.HKEY_LOCAL_MACHINE, inKeyName, 0, (int)RegSAM.QueryValue | (int)in32or64key, out hkey);
                if (0 != lResult) return null;
                uint lpType = 0;
                uint lpcbData = 1024;
                StringBuilder AgeBuffer = new StringBuilder(1024);
                RegQueryValueEx(hkey, inPropertyName, 0, ref lpType, AgeBuffer, ref lpcbData);
                string Age = AgeBuffer.ToString();
                return Age;
            }
            finally
            {
                if (0 != hkey) RegCloseKey(hkey);
            }
        }
        #endregion

        #region Enums
        #endregion
    }
}
Here is an example of using this class.
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace Read64bitRegistryFrom32bitApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string value64 = RegistryWOW6432.GetRegKey64(RegHive.HKEY_LOCAL_MACHINE, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization");
            string value32 = RegistryWOW6432.GetRegKey32(RegHive.HKEY_LOCAL_MACHINE, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOrganization");
        }
    }
}

Example 3 – Adding extension methods to the managed RegistryKey object that read the 64 bit registry from a 32 bit application or vice versa

You know what else is a cool idea? Making it an extension class to the normal managed registry C# code. So you can create a regular managed RegistryKey and then just call an extension function off it.
using System;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32;

namespace Read64bitRegistryFrom32bitApp
{
    /// <summary>
    /// An extension class to allow a registry key to allow it to get the
    /// registry in the 32 bit (Wow6432Node) or 64 bit regular registry key
    /// </summary>
    public static class RegistryWOW6432
    {
        #region Member Variables
        #region Read 64bit Reg from 32bit app
        public static UIntPtr HKEY_LOCAL_MACHINE = new UIntPtr(0x80000002u);
        public static UIntPtr HKEY_CURRENT_USER = new UIntPtr(0x80000001u);

        [DllImport("Advapi32.dll")]
        static extern uint RegOpenKeyEx(
            UIntPtr hKey,
            string lpSubKey,
            uint ulOptions,
            int samDesired,
            out int phkResult);

        [DllImport("Advapi32.dll")]
        static extern uint RegCloseKey(int hKey);

        [DllImport("advapi32.dll", EntryPoint = "RegQueryValueEx")]
        public static extern int RegQueryValueEx(
            int hKey, 
            string lpValueName,
            int lpReserved,
            ref RegistryValueKind lpType,
            StringBuilder lpData,
            ref uint lpcbData);

        [DllImport("advapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "RegQueryValueEx")]
        private static extern int RegQueryValueEx(
            int hKey,
            string lpValueName,
            int lpReserved,
            ref RegistryValueKind lpType,
            [Out] byte[] lpData,
            ref uint lpcbData);
        #endregion
        #endregion

        #region Functions
        public static string GetRegKey64(this RegistryKey inKey, String inPropertyName)
        {
            string strKey = inKey.ToString();
            string regHive = strKey.Split('\\')[0];
            string regPath = strKey.Substring(strKey.IndexOf('\\') + 1);
            return GetRegKey64(GetRegHiveFromString(regHive), regPath, RegSAM.WOW64_64Key, inPropertyName);
        }

        public static string GetRegKey32(this RegistryKey inKey, String inPropertyName)
        {
            string strKey = inKey.ToString();
            string regHive = strKey.Split('\\')[0];
            string regPath = strKey.Substring(strKey.IndexOf('\\') + 1);
            return GetRegKey64(GetRegHiveFromString(regHive), regPath, RegSAM.WOW64_32Key, inPropertyName);
        }

        public static byte[] GetRegKey64AsByteArray(this RegistryKey inKey, String inPropertyName)
        {
            string strKey = inKey.ToString();
            string regHive = strKey.Split('\\')[0];
            string regPath = strKey.Substring(strKey.IndexOf('\\') + 1);
            return GetRegKey64AsByteArray(GetRegHiveFromString(regHive), regPath, RegSAM.WOW64_64Key, inPropertyName);
        }

        public static byte[] GetRegKey32AsByteArray(this RegistryKey inKey, String inPropertyName)
        {
            string strKey = inKey.ToString();
            string regHive = strKey.Split('\\')[0];
            string regPath = strKey.Substring(strKey.IndexOf('\\') + 1);
            return GetRegKey64AsByteArray(GetRegHiveFromString(regHive), regPath, RegSAM.WOW64_32Key, inPropertyName);
        }

        private static UIntPtr GetRegHiveFromString(string inString)
        {
            if (inString == "HKEY_LOCAL_MACHINE")
                return HKEY_LOCAL_MACHINE;
            if (inString == "HKEY_CURRENT_USER")
                return HKEY_CURRENT_USER;
            return UIntPtr.Zero;
        }

        static public string GetRegKey64(UIntPtr inHive, String inKeyName, RegSAM in32or64key, String inPropertyName)
        {
            //UIntPtr HKEY_LOCAL_MACHINE = (UIntPtr)0x80000002;
            int hkey = 0;

            try
            {
                uint lResult = RegOpenKeyEx(inHive, inKeyName, 0, (int)RegSAM.QueryValue | (int)in32or64key, out hkey);
                if (0 != lResult) return null;
                RegistryValueKind lpType = 0;
                uint lpcbData = 1024;
                StringBuilder strBuffer = new StringBuilder(1024);
                RegQueryValueEx(hkey, inPropertyName, 0, ref lpType, strBuffer, ref lpcbData);
                string value = strBuffer.ToString();
                return value;
            }
            finally
            {
                if (0 != hkey) RegCloseKey(hkey);
            }
        }

        static public byte[] GetRegKey64AsByteArray(UIntPtr inHive, String inKeyName, RegSAM in32or64key, String inPropertyName)
        {
            int hkey = 0;

            try
            {
                uint lResult = RegOpenKeyEx(inHive, inKeyName, 0, (int)RegSAM.QueryValue | (int)in32or64key, out hkey);
                if (0 != lResult) return null;
                RegistryValueKind lpType = 0;
                uint lpcbData = 2048;

                // Just make a big buffer the first time
                byte[] byteBuffer = new byte[1000];
                // The first time, get the real size
                RegQueryValueEx(hkey, inPropertyName, 0, ref lpType, byteBuffer, ref lpcbData);
                // Now create a correctly sized buffer
                byteBuffer = new byte[lpcbData];
                // now get the real value
                RegQueryValueEx(hkey, inPropertyName, 0, ref lpType, byteBuffer, ref lpcbData);

                return byteBuffer;
            }
            finally
            {
                if (0 != hkey) RegCloseKey(hkey);
            }
        }
        #endregion

        #region Enums
        public enum RegSAM
        {
            QueryValue = 0x0001,
            SetValue = 0x0002,
            CreateSubKey = 0x0004,
            EnumerateSubKeys = 0x0008,
            Notify = 0x0010,
            CreateLink = 0x0020,
            WOW64_32Key = 0x0200,
            WOW64_64Key = 0x0100,
            WOW64_Res = 0x0300,
            Read = 0x00020019,
            Write = 0x00020006,
            Execute = 0x00020019,
            AllAccess = 0x000f003f
        }
        #endregion
    }
}
Here is an example of using these extension functions.
using Microsoft.Win32;

namespace Read64bitRegistryFrom32bitApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string value64 = string.Empty;
            string value32 = string.Empty;

            byte[] byteValue64 = new byte[1024];
            byte[] byteValue32 = new byte[1024];
            RegistryKey localKey = Registry.LocalMachine;
            
            localKey = localKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
            if (localKey != null)
            {
                value32 = localKey.GetRegKey32("RegisteredOrganization");
                value64 = localKey.GetRegKey64("RegisteredOrganization");

                // byteValue32 = localKey.GetRegKey32AsByteArray("DigitalProductId"); // Key doesn't exist by default in 32 bit
                byteValue64 = localKey.GetRegKey64AsByteArray("DigitalProductId");
            }
        }
    }
}
If anything is confusing please comment.
Resources:
  • RegOpenKeyEx Function – http://msdn.microsoft.com/en-us/library/ms724897%28v=VS.85%29.aspx
  • RegQueryValueEx Function – http://msdn.microsoft.com/en-us/library/ms724911%28VS.85%29.aspx
  • http://www.pinvoke.net/default.aspx/advapi32/RegQueryValueEx.html
  • http://www.pinvoke.net/default.aspx/advapi32/RegOpenKeyEx.html
  • http://www.pinvoke.net/default.aspx/advapi32/RegCreateKeyEx.html
  • http://www.pinvoke.net/default.aspx/advapi32/RegCloseKey.html
  • http://stackoverflow.com/questions/1470770/accessing-registry-using-net
  • http://connect.microsoft.com/VisualStudio/feedback/details/400597/registeredorganization-reg-key-on-x64-vista-7

Copyright ® Rhyous.com – Linking to this post is allowed without permission and as many as ten lines of this page can be used along with this link. Any other use of this page is allowed only by permission of Rhyous.com.

Russian Government going Open Source…and the future

Well, I have seen governments claim they are going to open source before, but not from Russia, and not with such a realistic plan to migrate over a few years.

Here is a link to the article via Google translate:

Putin ordered the transfer of power on Linux

The now

Business drives software development.  Open Source communities help, but even today much of the ongoing development for Linux is driven by businesses such as Red Hat and Novell and others.  If you think your Linux code is being written by unpaid developers in their spare time, you are somewhat correct but only partially.  Most changes are made by developers who are paid.

While communities are nice, they can’t match the hours or output of experienced developers working forty to sixty hours a week.

Looking Ahead…the Apps…and C# (Mono)

The more open source is used in business, the more development power it will have.  But it is not the open source Operatings Systems that prevent people from moving to Linux or BSD.  Ubuntu, SUSE, Fedora, CentOS, PC-BSD, and numerous others are all very usable desktops that are user friendly.  It is the software that runs on them that everyone is waiting for.

The market is already there to make millions extra if you application runs cross platform, one Windows, MAC, Linux, and BSD.

But most the applications written for Windows, the business desktop of today, are using .NET Framework. So naturally those companies are going to want to make their code cross platform.  And they are going to find it is easier than they thought to move their applications between platforms using C#.  I have recently decided that C# is the future of applications on all platforms.

Some MAC and Linux users don’t like Microsoft and will fight off the idea of a Microsoft provided development platform such as C# (Mono) on their systems.  But when a corporation decides that you must run software X, and software X requires .NET, and you have to either give up your MAC or Linux box for a Windows box, or use C# (Mono), then users will come around.

If you are a company writing software for Windows only today and using C#, you need to take a look at Mono. Even if the return on investment of developing a C# (Mono) based version of your product is a slight loss to break even, it is an investment in the future.  Once written, maintenance costs will be less than the original development costs and that slight loss to break even margin will turn to a small profit.  And with the experience, you next app will migrate to C# (Mono) that much easier and soon, all you apps will run anywhere that C# (Mono) can run.

This is going to take off in a way Java hasn’t because developers for windows prefer and will continue to prefer .NET over Java.  And when it comes to business apps, Java just isn’t the language of choice.  Business applications are written in C#.

Windows Live Messenger update broke again: Error 8100030d

Hey a few months ago, Windows Live Messenger was update by Microsoft.

Afterwards, it would not let me log in. It gave me this error and took me to this page:
Error 8100030d: Cannot Sign-in to Windows Live Messenger

That page did not help at all.

This page worked the first time:
How to perform Clean Installation of Windows Live Messenger

However, it was still very annoying.  And I complained the first time it happened.

Well, Windows Live was updated by Windows Update again, and yes, you guessed it, this same issue happened again.

A second time is just unacceptable.

Especially since neither of the websites above fix this.  I expected the second one to fix this again, but alas, it does not!

VMWare, RDP (MSTSC), WPF, and DisableHWAcceleration

I don’t know if you, like me, have a development box running Visual Studio 2010 and VMWare workstation. I develop in C# and WPF, and test the product in a VM. Then sometimes, when I work from home, I remote desktop into my development box.

When I am using RDP to remote control a VMWare Workstation host, and I run a WPF Application inside a VM, the WPF application doesn’t display. The window opens, and you see the frame of your windows, but the inside is just blank or a white/gray box. None of the WPF Controls are visible.

I have found two ways to fix this. One is permanent and one is temporary.

Option 1 – (Permanent) Set this registry key. Read more about this here on MSDN: Graphics Rendering Registry Settings

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Avalon.Graphics]
"DisableHWAcceleration"=dword:00000001

Option 2 – (Temporary) Or just reboot the VM while connected to the VMWare Workstation host via RDP. It seems that the VM boots and the OS detects the lack of support and disabled hardware acceleration. However, once you reboot when you are not RDP’ed into the VMWare Workstation host, you have hardware acceleration back.

I took me a long time to figure this out, because there was little to nothing in a Google search. I came across this solution while looking for something else a month or so ago, and needed to use it again when working from home last night. I thought I would post it so I never have to look for it again.

In Windows 7/2008, in Explorer, by default, Shift+Right-click in the white space gives you the “Open command window here” option

It is the simple things in life that makes one happy.

Did you know this:

In Windows 7/2008, in Explorer, by default, Shift+Right-click in the white space gives you the “Open command window here” option.

Installing Windows 7 into a virtual machine on FreeBSD using VirtualBox

My job at LANDesk requires that I write code in C# for an application that only runs on Windows Server.  I also have to test a lot of code on Windows 7. Like me, so many people are forced to run a version of Windows because they have special windows applications at work or because that is the platform we are developing for in our jobs.

If running windows is a must for you, as it is for me, then moving to FreeBSD exclusively is just not an option.  I want to run an FreeBSD, but running Windows 7 is a must too.

At first VMWare Workstation looked like it was going to solve this problem. But while its early versions worked on FreeBSD, they failed to port newer versions over.  Quemu just never could get to level of usability needed.  Well, along comes VirtualBox from Sun.  Sun, now Oracle, released an open source edition cleverly named VirtualBox Open Source Edition (OSE).  Like many of Sun’s code, it is duel licensed.

Prerequisites

  1. A FreeBSD desktop – Hopefully you are here because you already have this.  If you don’t have a FreeBSD desktop, you can follow my guide to build one.
    How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?
    Or you can install and use PC-BSD which is a nice desktop version of FreeBSD.
  2. A Windows 7 DVD or ISO and a product key.  Please do not pirate!

Step 1 – Installing VirtualBox OSE on FreeBSD 8.1

Installing VirtualBox is not complex. It involves only a few steps.

  1. Go to the directory for virtualbox-ose in your ports tree.
    # cd /usr/ports/emulators/virtualbox-ose
  2. Configure your installation.
    # make config
  3. Select Guest Additions, as it is not selected by default.
    Note: The defaults are Qt4, DBUS, X11, NLS and they should remain checked.
  4. You may also want to select VNC.
  5. Install virtualbox-ose
    # make install

Step 2 – Configuring FreeBD for Virtual Box

There are few things we need to configure on the FreeBSD system to make VirtualBox work.

  1. Add users to the vboxusers.
  2. Configure CD/DVD drive access.
  3. Configure VirtualBox kernel modules to load.

Step 2.1 – Adding use to the vboxusers group

  1. To add users to the group, use this command:
    FBSD# pw groupmod vboxusers -m SomeUserName

Step 2.2 – Configure CD/DVD drive access

Note: This is a copy of what is in my document for building a FreeBSD Desktop.

FreeBSD is more secure by default, so something as simple as accessing a CD or DVD or USB drive is not actually allowed by default. You have enable this.

These steps assume that your user is a member of the operator group. Remember above during the installation, I mentioned to make your user a member of both the wheel and operator groups.

  1. Access a shell and su to root.
    Note: The easiest shell to access now that you are in KDE is Konsole. To access Konsole, click the K and go to Applications | System | Terminal. Also you can add the shell icon to your panel by right-clicking on the icon and choosing Add to Panel.
  2. Enable vfs.usermount.
    FBSD# sysctl -w vfs.usermount=1
  3. Configure vfs.usermount to be enabled on boot.
    FBSD# echo vfs.usermount=1 >> /etc/sysctl.conf

  4. Open the following file with an editor: /etc/devfs.conf
    FBSD# ee /etc/devfs.conf

  5. Add the following lines:
    # Allow all users to access CD’s
    perm /dev/acd0 0666
    perm /dev/acd1 0666
    perm /dev/cd0 0666
    perm /dev/cd1 0666# Allow all USB Devices to be mounted
    perm /dev/da0 0666
    perm /dev/da1 0666
    perm /dev/da2 0666
    perm /dev/da3 0666
    perm /dev/da4 0666# Misc other devices
    perm /dev/pass0 0666
    perm /dev/xpt0 0666
    perm /dev/agpart 0666
    perm /dev/uscanner0 0666

    Note: Yes, I copied these from a PC-BSD install’s version of this file.

    Note: Change to 0660 to only allow users in the operator group to mount drives.

  6. Edit the /etc/devfs.rules file.
    FBSD# /etc/devfs.rules

  7. Edit the following file: /usr/local/etc/PolicyKit/PolicyKit.conf
    FBSD# ee /usr/local/etc/PolicyKit/PolicyKit.conf

  8. Change the xml’s config section from this…
    <config version="0.1">
        <match user="root">
            <return result="yes"/>
        </match>
        <define_admin_auth group="wheel"/>
    </config>
    

    …to this:

    <config version="0.1">
            <define_admin_auth group="operator"/>
            <match action="org.freedesktop.hal.storage.mount-removable">
                    <return result="yes"/>
            </match>
            <match action="org.freedesktop.hal.storage.mount-fixed">
                    <return result="yes"/>
            </match>
            <match action="org.freedesktop.hal.storage.eject">
                    <return result="yes"/>
            </match>
    </config>
    
  9. Edit the following file with ee: ee /etc/fstab
    FBSD# ee /etc/fstab

  10. See if there is a line in the fstab for your CD/DVD-Rom. Comment out or remove the line for your /cdrom. I usually just comment it out by adding a # sign as shown:
    #/dev/acd0 /cdrom cd9660 ro,noauto 0 0
  11. Restart the computer.

You should now be able to mount CD, DVD, and USB drives. You also should be able to both read and write to them, burn disks, write and format USB drives, etc…

Step 2.3 – Configure VirtualBox kernel modules to load

  1. As root, edit the /boot/loader.conf file.
    # ee /boot/loader.conf
  2. Add the following text:
    # VirtualBox
    vboxdrv_load=”YES”
  3. Save and close the file.
  4. Edit the /etc/rc.conf file.
  5. Add the following text.
    # VirtualBox
    vboxnet_enable
  6. Save and close the file.

Step 3 – Creating your Windows 7 VirtualBox

  1. Launch Virtual Box.
    Note: VirtualBox registers itself with the KDE menu.  On my installation, it was in Lost & Found, but on PC-BSD it was under System.  Either way you can type VirtualBox in the KDE menu search and find it.  Also, VirtualBox is the command and it should in $PATH so you should be able to open any shell from your desktop environment and run VirtualBox and have it open.
  2. Click New. This brings up a Wizard.
  3. Follow the wizard.
    Ok, if you need help with the wizard, here are my steps.
  4. Read and click Next.
  5. Choose an easy name.  I used “W7”.
  6. Make sure the Operating System is set to Microsoft Windows.
  7. Change the Version to Windows 7 (64-bit) or if you are on 32 bit hardware still use just Windows 7.
  8. Click Next.
  9. Allow at least 1536 MB (1.5 GB) for the base memory size.  You can get away with less if you need to. You can do better with more if
  10. you want to.
  11. Click Next.
  12. The Virtual Hard Disk page is already configured correctly, Boot Hard Disk is checked and Create new hard disk is selected. So just click next.
  13. Read and click Next.
  14. For Hard Disk Storage Type, I left it set at Dynamically expanding storage.
    Comment: This means that even if you use a 100 GB drive, it will only physically use as much space as Windows 7 has used in the Virtual Drive. So if Windows 7 is using 10 GB, even if you have 100 GB drive, the physical size on disk is only 10 GB.  This is important information for the next screen.
  15. Click Next.
  16. I change the drive size to 50 or 100 GB.
    Comment: It doesn’t really matter, but it is best to not run out of space either virtually or physically. Read my comment in the previous step.
  17. Click Next.
  18. Read and click Finish.

You virtual Machine now shows in the list.

Lets move to the next step.

Step 4 – (Optional) Changing Settings on your Windows 7 VirtualBox

I make two changes to my Windows 7 virtual box. As noted above this is optional, but I like to do them.

  1. Click the settings.
  2. Click System.
  3. Change the boot order to be hard drive first.
    Note: I make this change because it annoys me it when I install and then reboot the machine after the install and it boots right back to the install media. So I make this change and the press F12 during boot to the CD once.
  4. Uncheck and get rid of the floppy. (Does anyone still use those?)

  5. Now click on Storage.
  6. Under the Storage Tree, select your optical drive.
  7. If you are using an ISO, change the CD/DVD Device to point to the ISO. If you are using a DVD, as I am, choose Host Drive.  My host drive says: Host Drive Optiarc DVD RW AD-7910A (cd0).  I assume everyone drive will show up slightly different, but should start with Host Drive.
  8. Click OK.

Your settings should be good to go.

Step 5 – Install Windows 7

Now it is time to install Windows 7.

Don’t pirate! Use a legal product key. Again, just because I like open source does not make me anti closed source. I am not a Microsoft hater and I would hope you aren’t either. Even if you are, that is no excuse for pirating.

  1. Insert the DVD into your DVD drive, unless you are using an ISO and have already connected it.
  2. Click the Start icon.
  3. A new installation window will popup.
    Important! You may get a lot of popups telling you about important tips for using VirtualBox. Take time to read them. If you don’t read them or don’t already know what they are telling you, you will wish you had read them.
  4. Click in the window and to have it take control of your mouse and keyboard.
  5. Press F12 to choose your boot option.
     

    Note: If you miss this, that is OK,  you can restart the VM and try to be quicker.

  6. Once you have pressed F12 in time, you will see the following screen. At this screen, press the letter next to DVD drive.
  7. Press a key when prompted to boot to the Windows 7 media.

Well, you are off to installing Windows 7.  Hopefully you can get Windows 7 installed on your own, cause I am not here to walk you through doing that. Don’t worry, the install media for Windows 7 should be easy enough for you to follow if this is your first time.

Once finished, you will be running Windows 7 on FreeBSD.

Step 6 – Install VirtualBox Guest Additions

Even though all the devices are virtual, drivers are still needed. VirtualBox guest additions installs most of these drivers as well as other features of VirtualBox.

  1. Log in to your Windows 7 install.
  2. Select Device | Install Guest additions.

    This will mount an ISO and start the installer for VirtualBox Guest Additions inside Windows 7.

  3. Click Run VBoxWindowsEditions.exe.
  4. Follow the wizard.
    Note: I use the default install location and I check the option to Use Direct 3D support.
  5. Reboot when prompted.

Step 7 – Install the sound card driver

The sound card driver must be installed. VirtualBox uses a virtual device representing the Realtek AC’97 sound card.

  1. Log back into Windows 7.
  2. Go to the following web site:
    http://download.cnet.com/Realtek-AC-97-Driver-Windows-Vista-Windows-7/3000-2120_4-10962344.html
  3. Download and install the Realtek AC’97 Driver.
  4. Reboot when prompted.

Your Finished

You now have Windows 7 running. Now you can have the great experience of using FreeBSD as your primary OS and load Windows 7 when you need something requires windows, like I do.

Sources:
http://wiki.freebsd.org/VirtualBox
http://forums.freebsd.org/showthread.php?t=18699
The virtualbox-ose port’s pkg-message

Adding an alias in Windows 7 or making ls = dir in a command prompt

Hey all,

I don’t know about you but I switch between FreeBSD and Windows a lot.  So it drives me crazy when I type the command ls on windows and get the error message.

C:\Windows\system32>ls
‘ls’ is not recognized as an internal or external command,
operable program or batch file.

So I want this to go away.

I looked for the alias command in Windows and couldn’t find one.  So I made a batch file that solves this.

Windows doesn’t seem to have the equivalent of a .shrc or .cshrc or .bashrc. I couldn’t find a .profile either.  So I decided to go with the batch file route.

Option 1 – Using doskey

I was tipped off to this idea from a comment, which led my mind to the Command Prompt autorun registry I already knew about. But once I wrote the batch file, the parameters were not working, so I searched around and found an example of exactly what I wanted to do here:
http://bork.hampshire.edu/~alan/code/UnixInWin2K/

  1. Create a batch file called autorun.bat and put it in your home directory:
    My home dir is: c:\users\jared
  2. Add the following to your autorun.bat.
    @ECHO OFF
    doskey ls=dir /b $*
    doskey ll=dir $*
    doskey cat=type $*
    doskey ..=cd..
    doskey grep=find "$1" $2
    doskey mv=ren $*
    doskey rm=del $*
    
  3. Add the following key to the registry:
    Key:  HKEY_CURRENT_USER\Software\Microsoft\Command Processor
    REG_SZ  (String): Autorun
    Value:  %USERPROFILE%\autorun.batOr as a .reg file:

    Windows Registry Editor Version 5.00
    
    [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
    "Autorun"="%USERPROFILE%\\autorun.bat"
    

Now whenever you open a command prompt, the aliases will be there.

Option 2 – Creating a batch file as an alias

I created an.bat file that just forwards calls the original file and forwards all parameters passed when making the call.

Here is how it works.

Create a file called ls.bat. Add the following text.

ls.bat

@ECHO OFF
dir $*

Copy this batch file to your C:\Windows\System32 directory. Now you can type in ls on a windows box at the command prompt and it works.

How does this work to make your aliased command?

  1. Name the batch file the name of the alias.  I want to alias ls to dir, so my batch file is named ls.bat.
  2. In the batch file, set the RealCMDPath variable to the proper value, in my case it is dir.

So if you want to alias cp to copy, you do this:

  1. Copy the file and name it cp.bat.
  2. Edit the file and set this line:
    SET RealCMDPath=dir

Now you have an alias for both ls and cp.

Using different versions of msbuild.exe

You can also use this so you don’t have to add a path.

I need to use C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe but sometimes I want to use C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe. Both files are named the same. So I can easily use my alias command.

  1. Create two files in C:\Windows\System32: one named msbuild35.bat and one named msbuild40.bat.
  2. Change the line in each file to have the appropriate paths for the RealCMDPath.

Anyway, this is really a useful batch file.

VirtualBox: It seems ready

Ok, so because my work has given me a license to VMWare Workstation, I have never really gone to the trouble of using VirtualBox.

But I really want to move to use FreeBSD (well, PC-BSD) on my laptop but I have to have a Windows 7 box for work.

So I had Windows 7 with PC-BSD in a VMWare Virtual Machine.

However, I am switching that as we speak.

I now have PC-BSD installed as my primary operating system, and Windows 7 in a VirtualBox Virtual Machine.

There are some features we use at LANDesk a lot, such as many snapshots, and PXE booting, and more.  I will test and follow-up on whether this is a good solution for me.