Using a Windows 8 upgrade key for a clean install

I recently faced reinstalling a Windows 8 machine, without knowing the key used for deployment on it was an upgrade key. Not wanting to wipe the drive (again), dig up a Windows 7 key, then installing Windows 8 again, I googled and found this advice at Lifehacker, which worked brilliantly:

If you do a clean install using the Windows 8 Upgrade Assistant, you should be fine, but if you’ve already formatted your drive or you’re moving to a new drive, you can’t do a “clean install” without installing an old version of Windows first. It’ll let you install Windows 8 cleanly, but when you go to activate, you get an error 0x8007007B, saying your product key can only be used for upgrading.

If you get that error, here’s how to fix it:

  1. Press the Windows key and type regedit. Press enter to open the Registry Editor.
  2. Navigate to HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Setup/OOBE/ and double-click on the MediabootInstall key in the right pane.
  3. Change the key’s value from 1 to 0.
  4. Exit the Registry Editor, press the Windows key again, and type cmd. Right-click on the Command Prompt icon and run it as an administrator.
  5. Type slmgr /rearm and press Enter.
  6. Reboot Windows.

When you get back into Windows, you should be able to run the Activation utility and activate Windows as normal, without getting an error. Obviously, you could use this trick for evil, but it has its legitimate place too—if, say, you’re upgrading your hard drive and want to do a fresh install on it, or if you formatted your drive before upgrading.

Writing a newline to separate commands in XChat

Just learned something neat: In XChat, if you hold ctrl and shift, and then press “u”, followed by “a”, you get a weird character that signifies a line break. This can be used to put several commands on one line in the configuration, or to type several lines before spamming them all at once into a channel.


MSSQL Mass Copy

To avoid locking a table for a damn long time, this is how Google told me to do mass copies of data in Microsoft SQL Server:

DECLARE @BatchSize INT = 1000
DECLARE @IdMax INT = 25179272

WHILE @i <= @IdMax BEGIN
	INSERT INTO [mydata].[dbo].[ProjectEventValues] WITH (TABLOCK)
	FROM [mydata].[dbo].[ProjectEventValues_temp]s
	WHERE s.eventId >= @i AND s.eventId < (@i+@BatchSize)
	SET @i = @i + @BatchSize

Here for future reference.

SMPS Repair

I recently had to repair the Switched Mode Power Supply for my RockWheel (a one-wheeled electric “vehicle”). Looking around for some general guidelines, since I hadn’t touched line voltage in a while, I found this guide over here useful. Archived here for archival purposes…

Moving Windows’ Offline File Cache away from C:\

Got a small SSD as your C drive? So do I.
Storing your documents on a network drive? Yep.
Want to index that network drive, to include it in libraries, searches, etc? You bet.

You’ll want to move your offline cache.

  1. Create a folder for your offline file cache. Something like D:\Cache
  2. From an elevated command prompt type the following: takeown /r /f C:\Windows\CSC
  3. Open the Sync Center (typing “sync” into the start menu search field should do) and go to Manage Offline Files.
  4. Click Disable Offline Files and restart the machine.
  5. From an elevated command prompt issue the following commands:
    1. rd /s C:\Windows\CSC
    2. mklink /J C:\Windows\CSC "D:\Cache"
      (or whatever your folder name is, but be sure to use the quotes if you have space(s) in the name).
  6. Reopen the Manage Offline Files window and Enable Offline Files.
  7. Restart the machine.

Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list

This error seems to pop up every now and again when I configure a new IIS server, even if I do remember to check the ASP option during the initial role selection.

Here’s how to resolve it (run as admin) on a 64-bit system:

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

..and on a 32-bit system:

%windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe -i

Enabling read_committed_snapshot on an existing MSSQL database

In short, for the database named “internal”:

SELECT is_read_committed_snapshot_on, snapshot_isolation_state_desc,snapshot_isolation_state FROM sys.databases WHERE name='internal'
ALTER DATABASE [internal] SET allow_snapshot_isolation ON
ALTER DATABASE [internal] SET read_committed_snapshot ON
SELECT is_read_committed_snapshot_on, snapshot_isolation_state_desc,snapshot_isolation_state FROM sys.databases WHERE name='internal'

Typing the escape character ^] on a non-english keyboard

This works on a Norwegian keyboard, but may apply to others.

So, your terminal says something like:

Connected to foo
Escape character is ^]

So, ] is easily typed using “Alt Gr + 9″ on my keyboard, but “Ctrl + Alt Gr + 9″ does not produce an escape character.

However, “Ctrl + 5″ does, for whatever reason. If you have a non-english keyboard, try using ^5.

Removing VMware Player or workstation when the Hyper-V role is active

Blatantly stolen from Jussi Palo’s post here, and archived here.
All credit to the original author.


Time to go all in with Windows 8 and migrate development environments to Hyper-V.

When you’re migrating from VMware to Hyper-V, and you happen to install Hyper-V before uninstalling VMware Workstation or Player, you will get warning that VMware cannot uninstall while the Hyper-V role is installed on the machine.


Modify the file C:\ProgramData\VMware\VMware Player\Uninstaller\bootstrap.lua, or C:\ProgramData\VMware\VMware Workstation\Uninstaller\bootstrap.lua using a text editor. You may have to run that editor as an administrator and then open the file from within it.

Comment out the line:


…with two dashes, leaving it as:


Save the file, and attempt to uninstall VMware again.