Thursday, February 20, 2014

FocusMonitor Identifies Processes Stealing Focus

Recently I've been having issues with some process stealing focus from the application I'm working in.

Like I'll be in Visual Studio or Word or Waterfox (a 64-bit performance focused build of Firefox) and suddenly focus is swapped for a split second and whatever word I'm typing gets cut off or a button I'm clicking isn't.

I found a very helpful post by Matt Gertz from some years back where he provides some VB.NET code for an application that can monitor processes that steal focus from it. I'm more of a C# guy myself, so I've run with Matt's core logic and created a 32-bit C# application in Visual Studio 2010 which provides similar functionality. It will also let you copy the log info to the clipboard to paste wherever for further examination.




I call it FocusMonitor, and you can download the source code.





Sunday, February 2, 2014

Cannot Install Windows Updates

My Windows 7 install inexplicably began to have issues with installing updates.

Service pack 1 installed fine using an installer, but other incremental updates consistently failed, they would download but they'd be skipped by Windows Update and reported as having not been installed.

One fix involved deleting a folder and letting the update process recreate it, specifically this one:
C:\WINDOWS\SYSTEM32\catroot2

This folder contains part of an internal Windows database which it uses to track updates, and a log file, dberr.txt, which was rife with error messages like these:

CatalogDB: 6:27:32 PM 2/1/2014: catdbsvc.cpp at line #3454 encountered error 0x8007000e
CatalogDB: 6:27:32 PM 2/1/2014: catadnew.cpp at line #1915 encountered error 0x8007000e
CatalogDB: 2:16:29 PM 2/2/2014: catdbsvc.cpp at line #969 encountered error 0x8007000e

 
Interestingly, the error 0x8007000e was frequently returned as a response in the failed attempts to update.

Based on this seemingly corrupted database folder, I decided to try deleting it and then have Windows recreate it by taking the following steps, and now updates are again able to be installed.
  1. Open a command prompt with administrator access.
  2. Stop the Cryptographic Services, which normally has a lock on the above mentioned folder, by typing this: NET STOP cryptosvc
  3. Rename (or, if you're brave, delete) the C:\WINDOWS\SYSTEM32\catroot2 folder.
  4. Start the Cryptographic Services by typing: NET START cryptosvc
  5. Run Windows Update, and then have it download and install one or more updates to verify that it does so successfully.

After doing this I was able to download and install the latest updates successfully.