Tag Archives: windows

Script to change keyboard on Windows 7

I’m currently working in a client’s office, on an extremely locked-down Windows 7 PC. As usual, I want to change to the dvorak keyboard layout, which is my standard. However, the environment on the computer is reset every couple of days, which wipes out my keyboard setting.

So I started looking for a way to change it through a powershell script. Unfortunately, Windows 7 only has an extremely limited version of powershell. But I was able to find a way to change it using an xml script at these two sites:

https://msdn.microsoft.com/en-us/goglobal/bb964650?f=255&mspperror=-2147217396#eyb

https://superuser.com/questions/395818/how-to-change-keyboard-layout-via-command-line-cmd-exe-on-windows-xp-7

Combining them both together, I put together the following xml file:

<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">

<gs:UserList>
<gs:User UserID="Current"/>
</gs:UserList>

<gs:InputPreferences>

<!-- Add Dvorak -->
<gs:InputLanguageID Action="add" ID="0409:00010409"/>

<!-- Remove US default-->
<gs:InputLanguageID Action="remove" ID="0409:00000409"/>

</gs:InputPreferences>
</gs:GlobalizationServices>

The trickiest part was finding the code for the dvorak keyboard, which is 0409:00010409

The code to execute the xml file is:

control intl.cpl,, /f:"Desktop\changekeyboard.xml"

Which I then put into a .bat file which I keep on the desktop. So, whenever, the keyboard changes, I just double-click the bat file, and the keyboard is fixed again, and I end up with the keyboards as so:

Quad-boot Lenovo X220

After getting Mac OSX working fine on the Lenovo, I decided to reach higher and go for a real multi-boot setup – five OS’s! I wanted to put on Windows 8, so that I could play Steam games, and I wanted Linux to see how Linux has progressed over the last few years, and BSD just to see if I could.

My first step – upgrading the hard drive. The 320GB Seagate that I was using was fine for two partitions, but wouldn’t really cut it for more. So I bought a Seagate 7200rpm 750 GB Hybrid HD. With that done, I had to partition it up, which was quite a feat:

Disk Utility Screenshot

So that’s

  • 170GB for the original Windows Partition
  • 120GB for Mac OS X
  • 200GB for Windows 8 (pretty much only for Steam)
  • 60 GB for Linux
  • 50 GB for BSD and
  • 180 GB for general storage (formatted FAT, so that all the OS’s can share it.)

I used Mac OS’s Disk Manager for the partitioning – it does a good job, and it’s a lot harder to make some fatal mistakes.

Once that was done, it was a pretty straightforward, though time-consuming task to put all the OS’s on it. The Mac OS and Win 7 partitions I could copy straight across from the 320 GB drive. Windows 8 installed without too much hassle, but only once Windows 7 was on. It wouldn’t install into the non-first partition without another boot partition being in place.

For my Linux partition, I chose Ubuntu, which is definitely ‘flavour of the moment’. I’ve installed Linux in the past – Red Hat 3 on my old Pentium 2 300Mhz desktop computer, and Gentoo on a Sony Vaio Picturebook. Compared to those old installs, Ubuntu installed like a dream, I’d say fractionally easier than the Windows 8 install, and getting close to that of OSX.

I wasn’t completely thrilled with Ubuntu. It’s probably the Gnome-based Unity desktop, but I found a few of the OS choices to be quite annoying, particularly the dock on the left. There was also a surprising lack of configuration options in order to change the user experience. Sleep / wake worked just fine without any setting or configuration changes, which impressed me a lot.

One thing that impressed me though was the wireless connectivity. With my last Linux install – Gentoo on a Picturebook – getting wireless networking running required a lot of hard work, and a lot of editing of configuration files. However, Ubuntu made the experience as easy and fast as Windows or OSX does.

I was trying to go for five OS’s – with BSD being the fifth OS. Unfortunately, I wasn’t able to get it to work. It was very frustrating. The first time I tried to install it, I then discovered that it would only install into a primary partition, not into an extended partition. After much grinding of teeth, I re-partitioned the hard-drive and started from scratch.

I then moved Windows 8 to an extended partition, so that I could install BSD on a primary. Then, for some reason, I just could not create a bootable USB installer with BSD on it, it just wouldn’t work. The X220 doesn’t have a DVD-drive, so I had to go with a plan B – move the hard-drive across to another laptop which has a DVD-drive, then install, and move the HD back across for first boot.

Using this method, I was able to get PC-BSD installed and working, at least if they had full control of the bootloader. Once I tried to install another bootloader, to boot the other OS’s, then BSD would no longer work. I tried both the FreeBSD and the PC-BSD variants, but neither would boot. I eventually gave up. The BSD partition was only meant for ‘fun’ – a bit of icing on the cake, but it was proving to be more hassle than the rest of the OS’s put together.

Only after I had gone through all of that drama with installing on another computer that I realised that I had another install option. I could have used Virtualbox, and booted up the installer in Virtualbox, then installed on one of the other drives.

Getting the boot loader to work is generally a pain with these multi-boot installs, but I was able to get that sorted pretty easily. I used my Windows-to-go bootable USB to boot into Windows, and then I used EasyBCD to configure the boot loader on the computer. So my boot loader now looks like this:

IMG_1858

After I had got it all working, I went back and had another look at Ubuntu. I wasn’t completely happy with the Gnome environment. Fortunately, there’s an officially supported branch of Ubuntu called Kubuntu, which uses the KDE environment. I found this to be much more to my liking, and a lot more configurable. The only downside is that the wireless networking isn’t quite as easy or smooth as Ubuntu’s, and takes a bit longer to re-initialise itself after sleep.

All up, I’m now very happy with my work-issued Lenovo X220. It does absolutely everything I want, and can run any program I want. It’s got a good size and is extremely robust. I think that when it’s time to hand this computer back, I’ll go and pick up a 220 for myself.