Repairing Windows Update

Sometimes running Windows Update doesn't go smoothly, just like it happened to me when I tried to install Windows 8.1 Update 1 (KB2919355). I kept getting error code 80070002 which is never a good sign. The problem remained even after I wiped out the Windows Update download history manually and rebooted to seal the deal.

I had this kind of issue before, coincidentally only since I moved to Windows 8. Back then I researched the issue but didn't bother to write a troubleshooting guide on the subject. It's better late than never. Do the following steps and it might just fix your problem with Windows Update.

1. Scan and repair system files

Open an Elevated Command Prompt (as Administrator). On Windows 8 you can do this easily by pressing the keys Windows + X and selecting Command Prompt (Admin).

Run the following command: sfc /scannow

This scans the integrity of all protected system files and repairs files with problems when possible. It will take a few minutes but it has a progress indicator.

2. Troubleshoot and repair Windows Update

Open Troubleshooting from the Control Panel. Select System and Security and from this screen choose Windows Update - Resolve problems that prevent you from updating Windows. This is what you're going to get:

Troubleshooting and repairing Windows UpdateTroubleshooting and repairing Windows Update

Run it as Administrator, otherwise it will ask you to do so on the next screen, then it will try to resolve issues it finds. Usually it finds some stuff to fix.

3. Reboot

Don't skip this step, no matter how bad you want to.

4. Run Windows Update

You will see that your update history has been wiped out completely and even those updates will be found that you previously chose to hide. Install the updates you need, chances are it will work just fine. After you're done, probably you better reboot again, most updates will ask for it anyway.

If this trick doesn't solve your problem, I'm not sure what will, but it always helped me out so far.

Tube Headphone Amplifier

Sometime last year I decided it's time to get something nice to listen to music on when I'd prefer to isolate myself from noise while working at my desk. You know, like from a crying baby next door. I went for a Sennheiser HD 439 for the good sound quality and extended bass, detachable cable and comfortable ear cushions. It sounds really nice and provides plenty of noise isolation, while the music I listen to is barely audible for others. I really like it and I've been using it a lot ever since. Sometimes I even hook it up to the home theater.

The only problem is the impedance. It seems to be too much for my PC and depending on the audio file I listen to, it's not too loud even on 100% volume. I've been thinking about some good solution for a while, and then I found this cutie, the Bravo Audio V2 tube headphone amplifier.

Bravo Audio V2 tube headphone amplifier
Bravo Audio V2 tube headphone amplifier

Isn't it sweet? From the size of the connectors you can see it's really small. The part sticking out that resembles R2D2 is a vacuum tube and it's responsible for the tube sound preferred by audiophiles. I'm not one of them, far from it, but for $60 it was a cheap way to glance into that part of the world. Honestly, I can't hear much of a difference from a regular DAC, but obviously it's down to various factors, like the audio source, my headphones and mostly my hearing.

Still as an amplifier it works excellent, I got exactly what I wanted. The volume knob gives you control over all the volume you ever needed and much more, I don't think I'll ever have to go over 1/3rd, but conveniently I prefer to change the volume on the PC before it'd reach the amplifier, so I don't have to reach out and touch it. Partly because I'm lazy, but also because it can get hot and due to the open design the heat sinks are exposed.

Now after a while I think the heat issue is either a bit overblown in Amazon reviews, or I got a later revision where they decreased the amount of heat. I tried touching it and it's hot for sure, but it doesn't burn you unless you grab it and hold it for a longer period of time, but you probably wouldn't do that, right? And when you have the cables plugged in, it's hard to touch the heat sinks by accident. If you got kids, you may need to put it out of reach, but otherwise you'll be fine.

Even though I can't hear any significant difference, the amplifier does sound really nice it's not a real power hog, it takes about 5W according to my UPS. The vacuum tube is removable, so you can experiment with different tubes to get a different audio experience and they are generally around $15. I'll have to order something, either the same tube or a different type recommended by others who aren't deaf, because these tubes tend to die after a while. Let it be months or years, one day it will pop and then I better have a replacement at hand. Who knows, maybe even before that I'll try something different in it to see if the sound really gets warmer or something, but until then I'm just happy with what I have today. And it glows with a pleasant tone of blue light; looks nice at the corner of my desk, next to my purple lava lamp.

Maura Isles' MacBook Cover Case

If you're a fan of the TV series Rizzoli & Isles, you may have wondered before what cover case Maura Isles (Sasha Alexander) uses on her unibody MacBook Pro.

Maura Isles and her customized MacBook Pro
Maura Isles and her customized MacBook Pro

Wonder no longer: it's a Speck MegaPlaid for the MacBook Pro 13" (non-retina version), product code SPK-A1177. Unfortunately it's not in production anymore but Speck has a similar fabric cover case that's worth checking out too. If you want this exact case, you may do a search on ebay, there are a couple of them at the moment but by the time you read this, they might be all gone.

As much as I love it, sadly I won't get this one. I'm about to buy a new notebook soon and I'd be tempted to buy the previous generation MacBook Pro (2012) with the old display, because it would be all fine for my needs and frankly I love that computer, but at this point it would be foolish to go for it. It's about to be taken out of production so Mac OS X will not be supported for it much longer and after adding 16GB RAM and 256GB SSD, the price would be around the newest MBP's price with these options configured in, which is also a pound lighter, thinner, faster and runs several hours longer from battery. Sure it has a gorgeous Hi-DPI screen too, but I'm afraid that's going to cause serious issues with a virtualized Windows and even with web pages for quite a while and I'm not against visible pixels.

Still, this is certainly the way of the future so I better jump on the bandwagon right now, and to me the biggest selling point in this new model is the ~9 hours battery life. I intend to use it like my iPad, carry it around without worrying too much and hook it up to the charger only when it needs to be fed. My previous laptops had pathetic battery life, but maybe this one will give me the freedom from the plug I always wanted. Also my computer usage habits changed with age, mostly I'll use it for reading, writing and communication, with some programming when I feel like it. Hopefully there will be a nice case for it that I like so I can customize it. But it can wait, time is on my side.

Windows Phone AppResLib DLL Generator

A long time has passed since I wrote my WP7 AppResLib DLL Generator utility in 2011. I haven't actually used it ever since, but others do and I got a request to extend the title length limit to 80 characters, because Windows Phone 8 can display more text. The old limit was 32 characters that felt more than enough, but now you can put up to 80 characters long titles into the DLL files when you localize your Application Title (Display Name) and Tile Title for each of your supported languages.

I also attached the list of languages supported by Windows Phone 7.1 and Windows Phone 8.

Windows Phone AppResLib DLL GeneratorResource DLL generator for Windows Phone application title localization. Requires .Net Framework 4.0

CyberPower CP425G UPS

A few weeks ago I got myself this CyberPower CP425G uninterruptible power supply (UPS) while doing grocery shopping at Walmart, so you could say it was an impulse buy, especially because at a $45 price point it was cheaper than a video game. I've been thinking about getting something like this for a while, just for extra protection during short power outages, but I really didn't want to go overboard with it.

The power supply in my workstation is a SilverStone ST40F-ES with Active PFC, 80+ efficiency, the lot. I heard before how Active PFC power supplies often don't play along with cheaper UPS units, because those don't produce true sine wave when they power devices from the battery, only some rather square step approximation. I heard good things about CyberPower units, according to them they work with simulated sine wave, so it's worth a try; I can take it back to Walmart if it's not a good fit for me, no questions asked. I'd never get this peace of mind from any store in Hungary...

After setting it up and making sure it got all charged up overnight, I ran a little test with it – unplugged it while everything was running. Like as if nothing happened, my PC and display kept running without a twitch. The UPS produces 225W, my PC is quite beefy with an nvidia GTX660, it consumes around 90W when it's running in idle, writing code or browsing, including my 23" Apple Cinema Display. This UPS might be just enough for me, but it held on for a bit over 5 minutes, then it started beeping continuously to beg for power. I plugged it back, everybody was happy. I am still seriously impressed by all this.

Like you see it on the picture, it's quite a compact unit with 4 battery+surge covered outlets and 4 other with just surge protection. They are wide enough for power bricks too and the wall plug is in a 45 degree angle, leaving the bottom outlet uncovered and usable, which is quite a big deal given the poor design of the standard American wall outlets. You can route the phone line through it for extra protection, it will tell you if the UPS is overloaded and beeps once in every 30 seconds while it's running from battery; you can disable this alert.

The only oversight on my part was getting a unit without a USB port, for a bit more money you can get one that you can hook up to the PC or Mac and let it monitor the battery situation, so it can shut down the computer when the battery is way too low for safe usage. Fortunately it's not a deal breaker in case of my workstation, because I either work on it or it's asleep, and if I lose power for over 3 hours when I'm not at home, I don't care if I lose the state of RAM. But when I get one for the router, cable modem and home server, I will make sure I grab one with USB support.

If you haven't got a UPS yet, go and get one. I definitely feel more relaxed with it.

Update: Meanwhile I ordered a CP600LCD that I wanted to use in the living room with the home server, router, DVR etc but I ended up hooking it up to my workstation instead. It has a USB port and an LCD screen, showing all the interesting stuff you might want to see and can automate the shutdown process. At least now I see what the exact power consumption of my stuff is, it was less than what I anticipated earlier. I'll keep it here, the old one moved to the living room.

Clean Install With Windows 8 Upgrade Disc

When you're about to install Windows 8 using its upgrade disc, you're supposed to have an older version of Windows on the disk. Its presence will be noted and you can format the disk to make a clean install, or you can upgrade it which I prefer not to do. When you try it on a completely clean disk, Windows 8 will still install, but you won't be able to activate it due to the missing previous OS.

Top tip: If you ask nicely, it will allow your otherwise legal, purchased copy to activate.

Modify this key in the registry from 1 to 0:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ Windows\CurrentVersion\Setup\OOBE
MediaBootInstall = 0

Then run this from command line as Administrator:

slmgr /rearm

Reboot and you're done; you can activate your copy of Windows 8.

Macbook Hack

My little Macbook is about 6 years old now and I can't really justify its replacement yet, as it looks good and works pretty well, compared to ordinary PC laptops of its age. The performance of the Intel Core2 Duo 2.0 GHz (T7200) is quite enough for me in a secondary computer, the RAM could be faster (and bigger) and of course laptop HDDs are painfully slow, so there is room for improvement. It's hardly breaking news that you can fix some of these things with a little investment; I went a bit further in the process of modernizing.

Macbook 2,1 and some replacement parts
Macbook 2,1 and some replacement parts

What you see here is a 120GB Adata SSD, a hard disk caddy with the 500GB HDD that I put into my laptop years ago, 3GB RAM (the maximum this Macbook can handle), new CPU cooling fan, thermal paste, a new battery and an external optical drive. The "Superdrive" was about to die, so it was a good decision to replace it with a secondary HDD and the original battery was bent out of shape by now. It's best to follow these iFixit guides using proper tools, like the iFixit Pro Tech Toolkit that I ordered last year and I've been using it happily ever since. It's totally worth the money, especially for the ultimate screwdriver collection with 54 different bits.

After successfully taking off the top case (keyboard + touchpad), I took out the CPU cooler and the Superdrive and took off the heatsink to clean it, along with the CPU and the motherboard controller chip's surface, so I could add a fresh splash of thermal paste on them to improve cooling performance. The cooler itself wasn't in a too bad shape, but it's worth to get a new one on the cheap. The hard disk adapter is similarly cheap, you just have to keep in mind that this Macbook uses an IDE connector for the optical drive, so you need this one which converts SATA to IDE. Installing it is a bit harder, there are some rails and sticky stuff that you have to peel off the optical drive and put it on the caddy, to the same position, especially the Bluetooth antenna holder due to its limited cable length. Installing a primary SSD and RAM extension is easy, you don't have to take the laptop apart for that.

Macbook 2,1 internals after installing the replacement parts
Macbook 2,1 internals after installing the replacement parts

After it was all done and I put back all the parts, cables and screws, everything worked well for the first try. Well, except for the cheapo external DVD (18 bucks) that fails to work most of the time and I can't boot from any disc with it, no matter what I do. It's really a piece of junk, I won't return it only because mailing it back would cost half as much as the drive itself. I'll get a properly working optical drive when I really need it, luckily I already installed Windows 7 on the SSD (added it separately last year) and there was a Mac OS X 10.7 partition on the HDD, so these will work just fine for now. I bought a second Windows 8 Pro license that I could put onto the Macbook, but I don't think it's worth doing so, and it's good to have a Windows 7 machine around for testing.

To The Rescue

I've got sweet Adata 256GB SSD as the main drive in my workstation, but today's solid state drives are not reliable enough in my opinion. Theoretically when they die, they become a read-only flash media, but I've heard too many nightmare stories about SSDs suddenly go dead the next morning, without any chance to recover your data from it. Obviously the first thing you have to do is making frequent backups, but it's worth preparing for the total loss of the SSD (or your system HDD for that matter). What will you do until you can get it replaced? In a desktop computer there's plenty of space for my Plan B: having a bigger hard disk with a fresh (enough) copy of the SSD partitions, from which you can boot your computer and continue to work like if nothing happened.

For this you can kind of use the full system backup function in Windows, but if you ever tried it, you know about its limitations when it comes to restoring the image. It's much better to use the MiniTool Partition Wizard from which the Home Edition is free and has all the features we need to copy and activate partitions. It even lets you resize them while copying, so it's the perfect tool for the job. Also once you installed it, you can simply copy its folder from Program Files and use it in portable mode without the need to install it on any system. As it happens, it's a key feature because you shouldn't make a copy of your Windows partition while it's running, right?

I've been using a customized Windows PE (Preinstallation Environment) for these kind of rescue operations since the Vista days, it's basically a minimized version of Windows that you can boot from DVD or a USB flash drive and use for deployment, or simply for accessing and repairing a broken system. Now that I'm using Windows 8, it was time to create a new rescue media based on the new Windows PE 4.0 which now supports .Net Framework 4.5 applications and Windows PowerShell 3.0 if you set it up. It's not going to be a full blown guide to create a Windows PE image (there are dozens you can find) and I'll deal only with the latest version for Windows 8, even though the steps are roughly the same for previous versions of Windows PE. For extra content here are the official walkthrough guides for Windows 8 and for previous versions. It's also worth mentioning that I won't over-explain everything and I take no responsibility for your actions if you mess up something in your system. If you can't follow this guide, chances are you shouldn't deal with it at all.

Creating a customized Windows PE image

The first step is installing the Windows PE related bits from Windows Assessment and Deployment Kit (ADK) for Windows 8. The previous versions were called Windows AIK, search for it in the Download Center. Start the Deployment and Imaging Tools Environment as Administrator, all the build commands will be entered into this command window. Its default directory is this:

C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools

In this example I will use C:\WinPE as the working directory where the image will be assembled and I chose the x86 version to work on. You may create an amd64 version (apply your changes to the commands below) but it won't run 32 bit programs at all. To create an instance of the basic build, enter this command:

copype x86 C:\WinPE

It will create the C:\WinPE directory and a bunch of files in there. The Media directory is what we will put on the bootable media. The image we work on is under Sources\boot.wim and for customizing it needs to be mounted into an existing but empty directory, then it has to be unmounted to save the changes we made, back into the boot.wim file. We will use the C:\WinPE\Mount directory for this, note that it's empty. For mounting and unmounting we will use the following commands, you may create a batch file for both to make it easier to customize the image, probably you will do it several times before everything is perfect for you.

rem Mount the image into the work directory to customize
imagex /mountrw C:\WinPE\Media\Sources\boot.wim 1 C:\WinPE\Mount
rem Unmount and commit changes to the image
imagex /unmount /commit C:\WinPE\Mount

Once you mounted the image file, you can see its contents in the previously empty Mount directory. To avoid a lot of typing, create a batch file with the following commands that will install various packages into your image. You have to do it only once, the order of the packages do matter due to their dependency. You may check out the other packages in the WinPE_OCs directory and if you want to do custom localizations, you have to add your selected language resources beside the en-US versions. If you will use your Windows PE only in English, you are fine with this below.

rem Go into the x86 packages directory
cd /d "C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\WinPE_OCs"
rem Windows Script Host (WSH) support
dism /image:C:\WinPE\Mount /add-package /packagepath:""
dism /image:C:\WinPE\Mount /add-package /packagepath:"en-us\"
rem Windows Management Instrumentation (WMI) support
dism /image:C:\WinPE\Mount /add-package /packagepath:""
dism /image:C:\WinPE\Mount /add-package /packagepath:"en-us\"
rem Microsoft Data Access Component (MDAC) support
dism /image:C:\WinPE\Mount /add-package /packagepath:""
dism /image:C:\WinPE\Mount /add-package /packagepath:"en-us\"
rem HTML Application support
dism /image:C:\WinPE\Mount /add-package /packagepath:""
dism /image:C:\WinPE\Mount /add-package /packagepath:"en-us\"
rem .Net Framework 4.5 (subset but most features are supported)
dism /image:C:\WinPE\Mount /add-package /packagepath:""
dism /image:C:\WinPE\Mount /add-package /packagepath:"en-us\"
rem Windows PowerShell 3.0
dism /image:C:\WinPE\Mount /add-package /packagepath:""
dism /image:C:\WinPE\Mount /add-package /packagepath:"en-us\"
rem Windows PowerShell 3.0 cmdlets
dism /image:C:\WinPE\Mount /add-package /packagepath:""
dism /image:C:\WinPE\Mount /add-package /packagepath:"en-us\"
rem Allocated writeable memory in MB (32, 64, 128, 256, 512 - Default: 32)
dism /image:C:\WinPE\Mount /Set-ScratchSpace:512

With the same dism command you can make other changes, do localization and install optional device drivers, see the walkthrough links above but normally it's not necessary to do so.

Unmount the image (make sure absolutely nothing keeps the Mount directory open, file manager windows, command line or whatnot) and back up the boot.wim file if you want. If you made a mistake and you want to discard your changes, or there is a problem (open Mount directory for example) and the unmount command can't close your image, you should unmount it without adding /commit. Your basic Windows PE is pretty much ready but there are some other things you should add to it.

You should add ImageX which can be a very powerful tool to make backups into a single, optionally compressed wim file and restore it to the same partition or to a new disk. Copying the exe file itself may be enough, but you should just copy the contents of this directory into Windows\System32 of your image, mounted into the Mount directory:

C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools\x86\DISM\

Create a Tools directory in your image's root and put some tools in there, I always add Far Manager, command line tools like rar and zip, shortcut batch files, a text file with reminders of useful commands and the above mentioned Partition Wizard which will surely come handy. You may also add Raw Copy which is another tool to copy partitions and remember, you can add programs written for .Net Framework 4.0 / 4.5 too, they will run like a charm.

You should create/modify startnet.cmd in the Windows\System32 directory of your image, the commands you put in there will be executed when Windows PE opens its initial command line prompt. Beside displaying some info there with echo commands, I also do this (all between @echo on and @echo off lines) :

rem Put X:\Tools on path for easy access
set PATH=%PATH%;X:\Tools
rem Start Far Manager
cd \
regedit /s \Tools\Far\Far_Config.reg
start \Tools\Far\far.exe
rem Start Notepad with my reminder notes
start notepad.exe \Tools\readme.txt

When Windows PE is up, the image is loaded into a RAM Disk which gets the drive letter X by default. As you can see, I put the X:\Tools directory on path for quick access to the files in there, so I don't have to copy everything into the Windows directory, it's all nicely separated. Unmount the image and you're pretty much done, you just have to put it on a bootable media.

Creating a bootable Windows PE media

I recommend using a USB flash drive for this so it will be easy to change the image and add other stuff, not necessarily into the image but on the drive itself. In that case you have to figure out the assigned drive letter of your boot device in order to use them, PStart may help you out with that. To make the drive bootable, use these commands and at select disk you obviously have to enter the number of your pendrive you see in the list of disks.

list disk
select disk #
create partition primary
select partition 1
format quick fs=fat32

You can also use a rewritable DVD for this, for example my rusty Macbook and my wife's Macbook Pro refuses to boot from this flash drive (possibly a UEFI boot issue, DVD works), but it's bootable on everything else. At this point you can simply copy the contents of the Media folder to the drive, or use one of these commands:

rem Format the flash drive H: and copy the Media directory on it
MakeWinPEMedia /ufd C:\WinPE H:
rem Create a bootable ISO that you can burn onto a CD or DVD
MakeWinPEMedia /iso C:\WinPE C:\WinPE\WinPE.iso

Once your flash drive is ready and it works, you can simply replace the Sources\boot.wim file on it after you applied some changes, no need to format the drive again. If you don't want to deal with localization at all, you can remove the da-DK kind of directories in the Media directory and its sub-directories to clean it up, but you should keep en-US everywhere.

Disk partition backup and restore

Now that your Windows PE Rescue Disk is ready, you can do your periodical hard disk partition backups, and restore from them when it's necessary. For an always working copy of your system disk partitions, copy them with Partition Wizard to a secondary disk where you left out enough partitioned or unallocated space for them. You can use the rest for additional data storage, like I do on my workstation. If you want, you can create the partition during coping onto an unallocated space and can set a different size to expand or reduce it. Make sure you choose the same partition type (Primary for me) and set the copy of the system partition Active.

Backing up partitions with MiniTool Partition Wizard
Backing up partitions with MiniTool Partition Wizard

You can also use ImageX that you added to your Windows PE system, like this:

rem Backup partition C: into a single WIM file
imagex /capture C: D:\backup.wim "Backup"
rem Restore partition C: from a single WIM file
imagex /apply D:\backup.wim 1 C:

When you copied or restored the system partition, you have to make it bootable with the commands below, set up for Windows Vista or later versions. I used drive C: in this example but it works for any drive letter you want to handle, for example a bootable backup partition on another drive might be on E: after you assigned a drive letter to it.

bootsect /nt60 C: /mbr
bcdedit /set {bootmgr} device partition=C:
bcdedit /set {default} device partition=C:
bcdedit /set {default} osdevice partition=C:

That's it! According to my Plan B, if my SSD dies, I just make my HDD the primary disk and boot from it, restore some recent file backups and wait until I can get a new SSD because I'm way too addicted to its amazing speed by now. :-)