How to Test Your Code on Multiple Versions of Windows Using Only One Machine
A beta tester recently told me that ZitaFTP Server didn't work on his Windows Home machine. It works fine on my Windows 10 Pro machine (and also Windows Enterprise), so we suspect that it might be a Windows Home specific problem. Remote debugging is a pain, especially with Windows services. However, I only have one PC to test on, and don't want to buy a new computer just to be able to test it on Windows 10 Home.
Fear not though, because there's a simple solution: run Windows 10 Home in a virtual machine. Windows 10 Pro and higher comes with Hyper-V virtualization, which allows you to build and run virtual machines on your one device. This allows you to install and run multiple versions of Windows (and other operating systems) on one machine. Here's how it's done...
Installing and Running Windows in a Virtual Machine
Firstly, you will need Windows 10 Pro or higher. Windows Home does NOT come with Hyper-V.** Lots of RAM helps too. Assuming you have Hyper-V, the first step is to create an ISO image of the Windows installation DVD. Microsoft provide a tool for this, which you can download at:
Run it once downloaded. You'll have to wait a bit... and, as usual, accept the obligatory license agreement. Select "Create installation media" (shown below), and click next.
Next, select "ISO File," and click next (see below).
The generated DVD ISO image will be inserted into the virtual machine's virtual DVD drive in order to install Windows.
Generating the ISO file will take a while, so get up from your desk and do something else. Have a coffee... or two; it takes a long while.
Once it's done generating the ISO, start Hyper-V Manager. The easiest way is to click on the start menu and type "Hyper-V Manager." In Hyper-V Manager, right-click on your machine and select New -> Virtual Machine..., as shown below.
TIP: It's best to use the New -> Virtual Machine option instead of "Quick Create," which may create a poorly functioning virtual machine (as it did for me).
Now give the virtual machine a name. I called mine "Windows 10 Home," because it's going to be my Windows Home test machine. Call yours whatever makes sense for you. Then, follow the rest of the installation instructions.
Some quick tips:
- Deselect the "Use dynamic memory for the virtual machine" option. It caused Windows installation to fail for me
- Err on the small side with the hardfile. Hardfiles take up a lot of space, so create a virtual hard disk only as big as you're likely to need
- The "default switch" option works well for networking
When you get to the "Installation Options" page, choose "Install an operating system from a bootable image file" (shown below), and choose the Windows installation ISO that you generated earlier.
Click Next, then Finish, and it'll build the new virtual machine.
In the main Hyper-V Manager window, right-click on the new virtual machine, and select Connect. A window will open with a start button in the middle. Click that start button. Your new virtual machine will power up and come to life. Quickly push a key when it says "Press any key to boot from CD or DVD." If you're too slow, choose restart from the virtual machine's menu, and try again.
At this point, you'll see the start of the Windows installer (see below). Installation is as usual for any new machine.
Congratulations, you have a virtual machine running whatever version of Windows you need for testing.
Copying Your Code to The Virtual Machine For Testing
You'll need to copy your compiled code to the virtual machine before you can test it there. I was told that you could copy and paste files easily if the guest operating system is Windows 10. This is a remote desktop feature, and it's supposed to be enabled automatically. However, it didn't work for me.
An easy alternative is to enable network sharing. In the virtual machine, choose a folder to share (I used the Download folder). Right click on it, select Properties, click on the sharing tab, and enable sharing. You may also have to enable file and printer sharing in the main network settings. After this, you should be able to see your virtual machine listed on the network from the host operating system (i.e., the Windows running directly on your machine). For some reason I had to restart the virtual machine, before this happened.
With everything set up, you can now copy your code across to the virtual machine, and start testing.
** NOTE: You may be able to use some other virtualization system such as VMWare. I haven't tried that, though.
Post your comment