From http://sbs.seandaniel.com/2009/03/replacing-windows-applications-safe-way.html